akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    vector<vector<int>> dp(N + 1, vector<int>(T, 0));
    rep(i, N) {
        rep(j, T) {
            if (j < A[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - A[i]] + B[i]);
            }
        }
    }
    vector<bool> f(N, true);
    int U = T - 1;
    for (int i = N - 1; i >= 0; i--) {
        if (dp[i][U] == dp[i + 1][U]) continue;
        f[i] = false;
        U -= A[i];
    }
    //rep(i, N) if (f[i]) cout << i << endl;
    int m = 0;
    rep(i, N) if (f[i]) m = max(m, B[i]);
    cout << dp[N][T - 1] + m << endl;
}
/*
10 100
15 23
20 18*
13 17*
24 12*
18 29
19 27
23 21
18 20*
27 15*
22 25
*/

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
vector<vector<bitset<80*80*2+10>>> dp(8,vector<bitset<80*80*2+10>>(8));
class EBalancedPath {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		int h,w;
		cin >> h >> w;
		vector<vector<int>> a(h,vector<int>(w,0));
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				cin >> a[i][j];
			}
		}
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				int z;cin >> z;
				a[i][j] = abs(a[i][j] - z);
			}
		}
		const int d = 80*80*80 + 10;
		const int dd = d*2;

		vector<vector<bitset<dd>>> dp(h,vector<bitset<dd>>(w,0));

		dp[0][0][d-a[0][0]] = 1;
		dp[0][0][d+a[0][0]] = 1;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				if(i){
					dp[i][j] |= dp[i-1][j] >> a[i][j];
					dp[i][j] |= dp[i-1][j] << a[i][j];
				}
				if(j){
					dp[i][j] |= dp[i][j-1] >> a[i][j];
					dp[i][j] |= dp[i][j-1] << a[i][j];
				}
			}
		}
		int ans = dd;
		for (int i = 0; i < dd; ++i)
		{
			if(dp[h-1][w-1][i])ans = min(ans,abs(d-i));
		}
		cout << ans << endl;
	}
};




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


Measured memory_bytes: 810880
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    ll a[n];
    for(int i = 0; i<n; i++){
        cin>>a[i];
    }
    ll mn = 0;
    ll mx = 0;
    ll money = 1000;
    int i = 0;
    while(i < n - 1){
        if(a[i] <= a[i + 1]){
        mn = a[i];
        while(i < n - 1 && a[i] <= a[i + 1]){
            i++;
        }
        mx = a[i];
        ll stocks = money/mn;
        money -= stocks*mn;
        money += stocks*mx;
        }else{
            i++;
        }
    }
    cout<<money;
}


Measured memory_bytes: 3616
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int T = sc.nextInt();
    	int [] t = new int[N];
    	long X =0;
    	
    	for(int i=0; i<N; i++){
    	    t[i] = sc.nextInt();
    	}
    	
    	for(int i=0; i<N-1; i++){
    	    if(t[i+1]-t[i]<=T){
    	        X += t[i+1]-t[i];
    	    }
    	    else{
    	        X += T;
    	    }
    	
    	}
    	
    	System.out.println(X+T);
    	
    }
}

Measured memory_bytes: 64864
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll a;
    cin >> a;
    ll ans = a + a*a + a*a*a;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include <cstdlib>

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


typedef long long ll;
const int INF = 1001001001;

int dp[5005][5005];

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = n - 1; j >= 0; j--) {
			if (s[i] != s[j])dp[i][j] = 0;
			else dp[i][j] = dp[i + 1][j + 1] + 1;
		}
	}
	int ans = 0;
	rep(i, n)rep(j, n) {
		if (i >= j)continue;
		int now = min(dp[i][j], j - i);
		ans = max(ans, now);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 98048
#include <stdio.h>
#include <ctype.h>
int main(){
 char c;
 while(1){
  scanf("%c",&c);
  if(islower(c))
   printf("%c",toupper(c));
  else if(isupper(c))
   printf("%c",tolower(c));
  else
   printf("%c",c);
  if(c=='\n')
   break;}
 return 0;
}


Measured memory_bytes: 2048
while True:
    a,b,c = input().split()
    a = int(a)
    c = int(c)
    if b == "?":
        break
    elif b == "+":
        print(a + c)
    elif b == "-":
        print(a - c)
    elif b == "*":
        print(a * c)
    elif b == "/":
        print(a // c)


Measured memory_bytes: 5592
import java.util.*;
import java.io.*;
 
class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String []s = br.readLine().split(" ");
 
 
        double []pi = new double[N];

        for(int i=0; i < N; ++i)
            pi[i] = Double.parseDouble(s[i]);


        double [][]dp = new double[N+1][N+1];

        for(int i=0; i <= N; ++i)
            for(int j=0; j < i+1; ++j) {
                if (i == 0)
                    dp[i][j] = 1.0;
                else if (j == 0)
                    dp[i][j] = dp[i-1][j] * (1.0 - pi[i-1]);
                else
                    dp[i][j] = dp[i-1][j] * (1.0 - pi[i-1]) + dp[i-1][j-1] * pi[i-1];
            }

        double ans = 0;

        for(int i = (N+1)/2; i <= N; ++i)
            ans += dp[N][i];
        System.out.println(ans);
    }
}

Measured memory_bytes: 131152
//e4-e5-f4
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define sl set<ll>
#define usl unordered_set<ll>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vpl vector<pll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 1000000007
#define Q 1000000006
#define inf 1e18
#define N 200005
#define M 105
//using namespace boost::multiprecision; 
//using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);

ll n, sgt[4*N], dp[N];

void build(ll v, ll s, ll e) {
    if(s>e) return;
    if (s==e) {sgt[v] = dp[s]; return;}
    ll mid = (s+e)/2;
    build(2*v, s, mid);
    build(2*v+1, mid+1, e);
    sgt[v] = max(sgt[2*v],sgt[2*v+1]);
}

ll query(ll v, ll s, ll e, ll qs, ll qe) {
    if(qs>e || qe<s) return 0;
    if(qs<=s && qe>=e) return sgt[v];
    ll mid = (s+e)/2;
    ll left_ans = query(2*v,s,mid,qs,qe), right_ans = query(2*v+1,mid+1,e,qs,qe);
    return max(left_ans,right_ans);
}

void update(ll v, ll s, ll e, ll i, ll val){
    if(i<s || i>e) return;
    if(s==e) {sgt[v] = val; return;}
    ll mid = (s+e)/2;
    update(2*v,s,mid,i,val);
    update(2*v+1,mid+1,e,i,val);
    sgt[v] = max(sgt[2*v],sgt[2*v+1]);
}
void solve(){
    ll n;
    cin>>n;
    vl h(n+1), b(n+1);
    f(i,1,n+1) cin>>h[i];
    f(i,1,n+1) cin>>b[i];
    build(1,1,N);
    f(i,1,n+1){
        dp[h[i]] = b[i] + query(1,1,N,1,h[i]-1); // max: 1...(h[i]-1)
        update(1,1,N,h[i],dp[h[i]]);
    }

    ll ans = query(1,1,N,1,N); // max: 1...N
    cout<<ans;
}

signed main() {
    teevra_gati
        
    solve();

    return 0;
}

Measured memory_bytes: 11932
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,x,y;
  cin >> N>> K >> x >>y;
  int sum=0;
  for(int i=0; i<K && i<N; i++) sum += x;
  for(int i=K; i<N; i++) sum += y;
  cout << sum << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if (a==b){
    cout<<0<<endl;
  }else if((a+b)%2==1){
    cout<<"IMPOSSIBLE"<<endl;
  }else{
    cout<<(a+b)/2<<endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long x[3];
for(int i=0;i<3;i++)
    cin>>x[i];
for(int i=0;i<2;i++){
if(x[i]-x[2]>0){
    x[i]-=x[2];x[2]=0;}
else
   {x[2]=x[2]-x[i];x[i]=0;}
}
cout<<x[0]<<"  "<<x[1]<<endl;

return 0;}


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

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<unsigned long long int>;

void PrintVec(VI& v) {
    for (Int i = 0; i < v.size(); ++i) {
        cout << v[i] << endl;
    }
    return;
}

int main(void) {
    Int n;
    cin >> n;
    VI v(n);
    for (Int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    Int result = 0;
    for (Int i = 0; i < n; ++i) {
        Int target = v[i];
        while (v[i] % 2 == 0) {
            v[i] /= 2;
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define debug 1

int main() {
	int n;
	cin>>n;
	int h,h_last=0;
	for(int i=0;i<n;i++) {
		scanf("%d",&h);
		if(h>h_last) h--;
		else if(h==h_last) ;
		else if(h<h_last) {
			cout<<"No"<<endl;
			return 0;
		}
		h_last=h;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc109_c
{
	class Program
	{
		public static long Gcd(long a, long b)
		{
			Func<long, long, long> gcd = null;
			gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
			return a > b ? gcd(a, b) : gcd(b, a);
		}
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			for (int i = 0; i < x[0]; i++)
			{
				a[i] = Math.Abs(a[i] - x[1]);
			}
			if (x[0] == 1) Console.WriteLine(a[0]);
			else
			{
				long ret = Gcd(a[0], a[1]);
				for (int i = 2; i < x[0]; i++)
				{
					ret = Gcd(ret, a[i]);
				}
				Console.WriteLine(ret);
			}
		}
	}
}

Measured memory_bytes: 30932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
int main(){
	ll n;
	cin >> n;
	ll sum=0;
	rep(i,n+1){
		if(i%3==0||i%5==0)continue;
		sum+=i;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}

ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

struct BIT{
 int n;
 int MAX;
 vector<int> bit;
 BIT(){}
 BIT(int _n){
   n = _n;
   MAX = n +2;
   bit.resize(n+10,0);
 }
 
 int query(int x){
   int r=0;
   while(x>0){
     r+=bit[x];
     x-=(x&-x);
   }
   return r;
 }
 
 int query(int l,int r){
   return query(r) - query(l-1);
 }
 
 void update(int x,int val){
   while(x<MAX){
     bit[x]+=val;
     x+=(x&-x);
   }
 }
 

  
};

int32_t main(){
  fastio;
  int n;
  cin>>n;
  vector<int> v(n);
  const int MX = 1e6;
  BIT T(MX + 10);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());

  int res=0;
  for(int big = 0;big< n;big++){

    res+=T.query(v[big] + 1,MX);
   // cout << v[big]<<" "<<T.query(v[big],MX)<<endl;

    for(int i=0;i<big;i++){
      T.update(v[big] + v[i],1);
    }


  }
  cout << res << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 11116
n, m, c = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
sum = 0
n.times{
    a = gets.chomp.split.map(&:to_i)
    p = 0
    a.zip(b){|x, y| p += x * y}
    sum += 1 if p + c > 0    
}
puts sum

Measured memory_bytes: 1788
from itertools import accumulate


def make_dp(vvv, n, k):
    dp = [-(10 ** 9)] * (k + 1)
    dp[0] = 0

    for i in range(min(n, k)):
        i += 1
        vv = vvv[:i]
        vv.sort(reverse=True)
        sm = sum(vv)
        dp[i] = max(dp[i], sm)
        while i < k and vv and vv[-1] < 0:
            sm -= vv.pop()
            i += 1
            dp[i] = max(dp[i], sm)

    return list(accumulate(dp, func=max))


n, k = list(map(int, input().split()))
vvv = list(map(int, input().split()))

acl = make_dp(vvv, n, k)
vvv.reverse()
acr = make_dp(vvv, n, k)

ans = max(acl[i] + acr[k - i] for i in range(k + 1))
ans = min(ans, sum(v for v in vvv if v > 0))
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int dy[] = {0, -1, 0, 1, -1, 0, 1, -1, 0, 1};

int Solve(const string& S, int idx, int left, int right, bool prev)
{
  if(S.length() == idx) {
    return(0);
  } else if(prev) {
    if(dy[S[idx]] > dy[right]) return(Solve(S, idx + 1, left, S[idx], true) + 1);
    else return(Solve(S, idx + 1, S[idx], right, false));
  } else {
    if(dy[S[idx]] < dy[left]) return(Solve(S, idx + 1, S[idx], right, false) + 1);
    else return(Solve(S, idx + 1, left, S[idx], true));
  }
}
int main()
{
  string S;
  while(cin >> S, S != "#") {
    for(char& c : S) c -= '0';
    cout << min(Solve(S, 0, S[0], S[0], false), Solve(S, 0, S[0], S[0], true)) << endl;
  }
}

Measured memory_bytes: 3524
#include <cstdio>
#include <algorithm>

int main(){
  long long N,A,B;
  scanf("%lld %lld %lld",&N,&A,&B);
  if((B-A)%2==0){
    printf("%lld\n",(B-A)/2);
  }else{
    long long d=std::min(A+B-2,N-A+N-B);
    printf("%lld\n",(d+1)/2);
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

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 k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;


double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps && abs(B)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

Polygon convex_cut(Polygon p,Line l){
  Polygon ans;
  for(int i=0;i<p.size();i++){
    Point A=p[i],B=p[(i+1)%p.size()];
    if(ccw(l.p1,l.p2,A)!=-1)ans.push_back(A);
    if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0)
      ans.push_back(getCrossPointLL(l,Segment(A,B)));
  }
  return ans;
}

double getPolygonArea(Polygon p){
  double area=0.0;
  int n=p.size();
  for(int i=0;i<n;i++)area+=cross(p[i%n],p[(i+1)%n]);
  return area/2;
}

Point rotationPoint(Point base,Point a,double r){
  Point b=a-base;
  a.x=b.x*cos((r/180)*M_PI)-b.y*sin((r/180)*M_PI);
  a.y=b.x*sin((r/180)*M_PI)+b.y*cos((r/180)*M_PI);
  a=a+base;
  return a;
}

Line Parallelmove(Line L,double dis){
  Vector v1,v2;
  v1=(rotationPoint(L.p1,L.p2,90)-L.p1);
  v2=(rotationPoint(L.p2,L.p1,270)-L.p2);
  v1=(v1/abs(v1))*dis;
  v2=(v2/abs(v2))*dis;
  return Line(L.p1+v1,L.p2+v2);
}

int n;
Polygon p;

bool ok(double mid){
  Polygon cp=p;
  for(int i=0;i<n;i++){
    Line L(p[i],p[(i+1)%n]);
    L=Parallelmove(L,mid);
    cp=convex_cut(cp,L);
  }
  if(cp.size()>=3)return true;
  return false;
}
int main()
{
  int x,y;

  while(1){
    cin>>n;
    if(n==0)break;
    p.clear();
    for(int i=0;i<n;i++){
      cin>>x>>y;
      p.push_back(Point(x,y));
    }

    double r=1<<30,l=0,mid;
    for(int i=0;i<100;i++){
      mid=(r+l)/2;
      if(ok(mid))l=mid;
      else r=mid;
    }
    printf("%.10f\n",mid);
  }

  return 0;
}

Measured memory_bytes: 1244
use std::collections::{BTreeMap, BTreeSet, VecDeque};
const INF: i64 = 1 << 50;
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();

    let mut graph = BTreeMap::new();
    let mut base_graph = vec![BTreeSet::new(); n];
    let base = 0;
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        let c = sc.read::<usize>();

        graph.entry((a, c)).or_insert_with(BTreeSet::new).insert(b);
        graph.entry((b, c)).or_insert_with(BTreeSet::new).insert(a);
        base_graph[a].insert(c);
        base_graph[b].insert(c);
    }

    let mut queue = VecDeque::new();
    let mut dist = BTreeMap::new();
    dist.insert((0, base), 0);
    queue.push_front((0, base));
    while let Some((v, c)) = queue.pop_front() {
        if v == n - 1 {
            println!("{:?}", dist[&(v, c)]);
            return;
        }

        let d = dist[&(v, c)];

        if c == base {
            for &next_c in base_graph[v].iter() {
                let cur = dist.entry((v, next_c)).or_insert(INF);
                if *cur > d + 1 {
                    *cur = d + 1;
                    queue.push_back((v, next_c));
                }
            }
        } else {
            for &next in graph[&(v, c)].iter() {
                let cur = dist.entry((next, c)).or_insert(INF);
                if *cur > d {
                    *cur = d;
                    queue.push_front((next, c));
                }
            }

            let cur = dist.entry((v, base)).or_insert(INF);
            if *cur > d {
                *cur = d;
                queue.push_front((v, base));
            }
        }
    }

    println!("-1");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

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


Measured memory_bytes: 110844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
LL N;

bool valid(LL x){
    LL A = N;
    while(A >= x){
        if(A % x == 0){
            A /= x;
        }else{
            A %= x;
        }
    }
    if(A == 1) return true;
    else return false;
}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    cin >> N;
    set<LL> cand;
    for(LL i = 2; i*i <= N-1; i++){
         if((N-1)%i == 0){
             cand.insert(i);
             cand.insert((N-1)/i);
         }
    }
    for(LL i = 2; i*i <= N; i++){
         if((N)%i == 0){
             cand.insert(i);
             cand.insert((N)/i);
         }
    }
    cand.insert(N);
    if(N != 2) cand.insert(N-1);
    LL ans = 0;
    for(LL i : cand){
        if(valid(i)){
            ans++;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int gcd(int x,int y);
int main(){
	int a,b;
	cin >> a >> b;
	cout<< gcd(a,b) << endl;
	return 0;
}
int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}

Measured memory_bytes: 1160
n = int(input())

xyh = []

for i in range(n):
    x, y, h = map(int, input().split())
    xyh.append([x, y, h])

xyh.sort(reverse=True, key=lambda x: x[2])

for i in range(101):
    for j in range(101):
        px, py, ph = xyh[0]
        H = ph + abs(px - i) + abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y -j), 0) for x, y, h in xyh):
            print(i, j, H)
            break

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

int bubbleSort(char (*a)[3], int n){
    int i = 0;
    char tmp;
    int c;
    int flag = 1;
    while(flag){
        flag = 0;
        for(int j=n-1;j>i;j--){
            if(a[j][1]<a[j-1][1]){
                tmp = a[j][0];
                a[j][0] = a[j-1][0];
                a[j-1][0] = tmp;
                tmp = a[j][1];
                a[j][1] = a[j-1][1];
                a[j-1][1] = tmp;
                flag = 1;
                c++;
            }
        }
        i++;
    }
    return c;
}

int selectionSort(char (*a)[3], int n){
    int i, j, minj;
    char tmp;
    int c = 0;
    for(i=0;i<n;i++){
        minj = i;
        for(j=i+1;j<n;j++){
            if(a[j][1]<a[minj][1])minj = j;
        }
        if(minj!=i){
            tmp = a[i][0];
            a[i][0] = a[minj][0];
            a[minj][0] = tmp;
            tmp = a[i][1];
            a[i][1] = a[minj][1];
            a[minj][1] = tmp;
            c++;
        }
    }
    return c;
}

int stability(char (*in)[3], char (*out)[3], int n){
    int i,j,a,b;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(a=0;a<n;a++){
                for(b=a+1;b<n;b++){
                    if(in[i][1]==in[j][1]&&in[i][0]==out[b][0]&&in[i][1]==out[b][1]&&in[j][0]==out[a][0]&&in[j][1]==out[a][1])return 1;
                }
            }
        }
    }
    return 0;
}

int main(){
    int i, n, count_select, count_bubble;
    scanf("%d",&n);
    char (*a)[3] = new char [n][3];
    char (*b)[3] = new char [n][3];
    char (*s)[3] = new char [n][3];
    for(i=0;i<n;i++)scanf("%s",a[i]);

    for(i=0;i<n;i++){
        strcpy(b[i],a[i]);
        strcpy(s[i],a[i]);
    }

    count_bubble = bubbleSort(b,n);
    count_select = selectionSort(s,n);

    for(i=0;i<n;i++){
        if(i>0)printf(" ");
        printf("%s",b[i]);
    }
    if(stability(a,b,n)){
        printf("\nNot stable\n");
    }else{
        printf("\nStable\n");
    }

    for(i=0;i<n;i++){
        if(i>0)printf(" ");
        printf("%s",s[i]);
    }
    if(stability(a,s,n)){
        printf("\nNot stable\n");
    }else{
        printf("\nStable\n");
    }
    return 0;
}




Measured memory_bytes: 2736
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K,A,B;
    cin >> K;
    cin >> A >> B;
    string ans ="NG";
    for(int i = A; i <= B;i++){
        if(i%K==0)ans ="OK";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
	    long n = sc.nextLong();
		long n2 = sc.nextLong();
		System.out.println(n * n2 / gcd(n , n2));

	}
	 public static long gcd(long num1,long num2) {
	        if(num2 == 0) return num1;
	        else return gcd(num2 , num1 % num2 );
	 }
}



Measured memory_bytes: 35668
a, b, c, x, y = map(int, input().split())

ab = max(x, y) * 2 * c
a_b = a * x + b * y
if x >= y:
    ab_a_b = y*2*c + (x-y)*a
else:
    ab_a_b = x*2*c + (y-x)*b

print(min(ab, a_b, ab_a_b))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
 
using namespace std;
 
#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define REP1(i,n) for(int (i)=(1);(i)<(n);++i)
#define ll long long
 
int main(){
    int n,l,st,ans = 0;
    bool flag = false;
    cin >> n >> l;

    if(l>=0)st = l+1;
    else if(l-1+n<=0)st = l;
    else {
        flag = true;
        st = l;
    }

    REP(i,n-1){
        ans += st;
        st++;
    }

    if(flag)ans+= l+n-1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);rep(i,n){cin>>a[i];}
    function<ll()> solve = [&](){
        ll sum = 0,cnt=0;
        rep(i,n){
            if(i==0){
                sum = a[0];
                continue;
            } 
            if(sum>0&&sum+a[i]>=0){
                cnt += sum+a[i]+1;
                sum=-1;
            }else if(sum<0&&sum+a[i]<=0){
                cnt += -(sum+a[i])+1;
                sum=1;
            }else{
                sum += a[i];
            }
        }
        DEBUG{
            printf("cnt: %lld\n",cnt);
        }
        return cnt;
    };
    ll res;
    if(a[0]==0){
        a[0]=1;
        res = solve();
        a[0]=-1;
        chmin(res, solve());
        res++;
    }else if(a[0]>0){
        res = solve();
        ll tmp = a[0];
        a[0] = -1;
        DEBUG{
            cout << tmp << endl;
            cout << res << endl;
        }
        chmin(res, solve()+tmp+1);
        
    }else{
        res = solve();
        ll tmp = a[0];
        a[0] = 1;
        chmin(res, solve()-tmp+1);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}

// O(n * W)

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly i
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
  cout << dp[W];
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); 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; }
const ll MOD = 1e9+7;
const ll INF = 1e15;

#define MAXV 1100*100

ll DP[120][2*MAXV];

int main(){
    ll N, W;
    cin >> N >> W;

    vector<pair<ll, ll> > L;
    REP(i,N){
        ll w, v;
        cin >> w >> v;
        L.emplace_back(w,v);
    }

    REP(i,N+1){
        REP(j,2*MAXV){
            DP[i][j] = INF;
        }
    }

    DP[0][0] = 0;
    REP(i,N){
        auto p = L[i];
        ll w = p.first;
        ll v = p.second;
        REP(j,MAXV){
            if(DP[i][j] == INF) continue;
            chmin(DP[i+1][j+v], DP[i][j] + w);
            chmin(DP[i+1][j], DP[i][j]);
        }
    }

    //REP(i,100){
    //    printf("%d : %lld\n", i, DP[N][i]);
    //}

    ll ans = 0;
    REP(i,MAXV+1){
        if(DP[N][i] <= W)
            ans = i;
    }

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


Measured memory_bytes: 174336
/*   LazyBones
*
*/

#include <bits/stdc++.h>
#include<cctype>
#include <sstream>
#include<ctime>
using namespace std;
#define rep(i,b) for(int i=0;i<b;i++)
#define getarr(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define disparr(a,n) for(int i=0;i<n;i++){cout<<a[i];}cout<<"\n";
#define disparrs(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";
#define disparrl(a,n) for(int i=0;i<n;i++){cout<<a[i]<<"\n";}cout<<"\n";
#define mem0(a) memset(a,0,sizeof(a));
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define pob pop_back
#define pof pop_front
#define pf push_front
#define mp make_pair
#define F first
#define S second
//#define nu 100001
#define M 1000000007
#define mul(x,y) ((ll)(x)*(y))%M
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 0x3f3f3f3f
#define MOD 998244353

int MODU(int a, int b)
{
    if(a>b)
    return a-b;
    else
    return b-a;
}
ll max3(ll a,ll b,ll c)
{
    return max(c,max(a,b));
}
ll power(ll x,ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll max(ll a,ll b)
{
    return (a>b)?a:b;
}
ll min(ll a,ll b)
{
    return (a<b)?a:b;
}
ld min(ld a,ld b)
{
    return (a<b)?a:b;
}
ll gcd(ll a,ll b)
{
    if(b==1)
    return 1;
    else if(a%b==0)
    return b;
    else
    return gcd(b,a%b);
}
ll mod(ll x){
    if(x>=0)
    return x;
    else
    return -x;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

void cycle(vll c,vi& v,int u, ll& val,vi& len,int ini){
    //cout<<u<<endl;
    v[u]=1;
    if(c[u]==u){
        v[u]=2;
        val=1;
        return;
    }
    if(v[c[u]]==2){
        return;
    }
    if (v[c[u]]==1){
        if(v[c[u]]!=ini)
            return;
        val=len[u]+1-len[c[u]];
        //cout<<val<<" hf"<<endl;
        v[u]=2;
        return;
    }
    len[c[u]]=len[u]+1;
    //cout<<u<<endl;
    cycle(c,v,c[u],val,len,ini);
    v[u]=2;
    return;

}



int main()
{
    fastio;
    int n,m,c;
    cin>>n>>m>>c;
    vi b(m);
    getarr(b,m)
    vi a(m);
    int cnt=0;
    rep(i,n){
        getarr(a,m)
        int res=0;
        rep(j,m){
            res+=b[j]*a[j];
        }
        if(res+c>0)
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define D(i, a, b) for (int i = (a); i >= (b); i--)
#define R(i, a, b) for (int i = (a); i < (b); i++)
#define N 500000
#define ALL(vt) vt.begin(), vt.end()
#define ALLR(vt) vt.rbegin(), vt.rend()
int main(){
    int r,g, pr,pg,pc; cin >> r >> g >> pr >> pg >> pc;
    vector<int> vpr(pr), vpg(pg), vpc(pc), temp;
    R(i, 0, pr) cin >> vpr[i];
    R(i, 0, pg) cin >> vpg[i];
    R(i, 0, pc) cin >> vpc[i];    
    sort(ALLR(vpr));
    sort(ALLR(vpg));
    sort(ALLR(vpc));
    ll ans = 0;
    R(i, 0, r){
        temp.push_back(vpr[i]);
        ans += vpr[i];
    }
    R(i, 0, g){
        temp.push_back(vpg[i]);
        ans += vpg[i];        
    }    
    sort(ALL(temp));
    int numr = r + g;
    for(int i = 0; i < pc && (i < r + g); ++i){
        if(vpc[i] > temp[i] && numr > 0) {
            ans -= temp[i];
            ans += vpc[i];
            --numr;
        }
    }
    cout << ans;
    
}

Measured memory_bytes: 2552
// problem: "https://atcoder.jp/contests/abc126/tasks/abc126_e"

#include<iostream>
#include<vector>

using namespace std;

bool dfs(vector<int>G[],int i,vector<bool>&V)
{
    if(V[i])
        return false;

    V[i] = true;
    int j;
    for(j=0;j!=G[i].size();j++)
        dfs(G,G[i][j],V);

    return true;
}

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

    vector<int>G[n+1];
    while(m--)
    {
        int x,y,z;
        cin>>x>>y>>z;

        G[x].push_back(y);
        G[y].push_back(x);
    }

    int i,c;
    c = 0;
    vector<bool>V(n+1,false);
    for(i=1;i!=n+1;i++)
        if(dfs(G,i,V))
            c++;

    cout<<c;

    return 0;
}


Measured memory_bytes: 10368
import sys
input = sys.stdin.buffer.readline

N,Q = map(int,input().split())
BIT = [0]*(N+1)

def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

def BIT_update(idx,x):
    while idx <= N:
        BIT[idx] += x
        idx += idx&(-idx)
    return

c = [0]+list(map(int,input().split()))
lastAppeared = [-1]*(N+1)
ans = [0]*Q
queries = []
for q in range(Q):
    l,r = map(int,input().split())
    queries.append(r*10**12+l*10**6+q)
queries.sort()

curR = 0
for i in range(Q):
    query = queries[i]
    r = query//10**12
    query %= 10**12
    l = query//10**6
    q = query % 10**6
    while curR < r:
        curR += 1
        color = c[curR]
        last = lastAppeared[color]
        if last != -1:
            BIT_update(last,-1)
        lastAppeared[color] = curR
        BIT_update(curR,1)
    ans[q] = BIT_query(r)-BIT_query(l-1)
for i in range(Q):
    print(ans[i])


Measured memory_bytes: 159596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<long>power(N*3,0);
  
  for(int i=0;i<N*3;i++){
    cin >> power[i];
  }

  sort(power.begin(),power.end(),greater<long>());
  
  long ans = 0;
  
  for(int i=0;i<N;i++){
    ans += power[i * 2 + 1];
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int start, end;
	int year;
	int flg_null;
	int flg_dsp;
	
	flg_null = 0;
	while (1){
		scanf("%d%d", &start, &end);
		if (start == 0 && end == 0){
			break;
		}
		if (flg_null == 1){
			printf("\n");
		}
		flg_null = 1;
		flg_dsp = 0;
		for (year = start; year <= end; year++){
			if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){
				printf("%d\n", year);
				flg_dsp = 1;
			}
		}
		if (flg_dsp == 0){
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

struct query{
    int a;
    int b;
    int c;
    int d;
};
vector<query> problems;

int best = 0;
int n,m,qu;

int val[11];

void choose(int start, int sval){
    if(start == n+1){
        int total = 0;
        FOR(i,qu){
            if(val[problems[i].b]-val[problems[i].a] == problems[i].c) total += problems[i].d;
        }
        best = max(best,total);
    }else{
        F0R(i,sval,m){
            val[start] = i;
            choose(start+1,i);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> qu;
    int dp[11][11][11][11];
    int dp2[11][11];
    m0(dp); m0(dp2);
    FOR(i,qu){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        query k = {a,b,c,d};
        problems.push_back(k);
    }
    choose(1,1);
    cout << best << endl;
    return 0;
}


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

int main(){
  string s; cin >> s;
  int ans = 1e9;
  
  for(int i = 0; i < s.size() - 2; i++){
    int n = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 +(s[i+2] - '0');
    ans = min(ans, abs(n - 753) );
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
X = int(input())
fact = [(i,i**5) for i in range(-10**3,10**3)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)
    

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

using ll = long long;

const int mod = 1e9 + 7;

int n;

int main() {
    cin >> n;
    ll A = 1, B = 1, C = 1;
    for(int i = 1; i <= n; i++) {
        A = A * 10 % mod;
        B = B * 9 % mod;
        C = C * 8 % mod;
    }
    cout << (A - 2LL * B + C + 10LL * mod) % mod << '\n';
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int N,M;
    scanf("%d",&N);
    scanf("%d",&M);
    if(M==1||M==2*N-1){
        puts("No");
    }else{
        puts("Yes");
        int cnt = 2;
        for(int i=1;i<=2*N-1;i++){
            if(i==N-1){
                puts("1");
            }else if(i==N){
                printf("%d\n",M);
            }else if(i==N+1){
                printf("%d\n",2*N-1);
            }else{
                if(cnt==M)cnt++;
                printf("%d\n",cnt++);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int s=0;s<c;s++)
	{
		if(s%2)
		{
			if(b%2)b--;
			a+=b/2,b/=2;
		}
		else
		{
			if(a%2)a--;
			b+=a/2,a/=2;
		}
	} 
	cout<<a<<" "<<b<<endl;
}

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

const int INF = 1 << 30;
const int INI = 0;
int N, W, w[200], v[200];
long long int dp[200][101010];

int main(){
  //入力
  cin >> N >> W;
  rep(i, N){
    cin >> w[i] >> v[i];
  }
  //dp配列の初期化
  rep(i, N + 1){
    rep(j, W + 1){
      dp[i][j] = INI;
    }
  }
  //dp本体
  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= W; j++){
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      if(j - w[i - 1] >= 0){
        dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      }
    }
  }
  
  //デバッグ（dp配列の出力
  
  //出力
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll e=max(a*c,a*d);
  ll f=max(b*c,b*d);
  cout<<max(e,f)<<endl;
  return 0;
}

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

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

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

#define MAX_N 100
#define INF (1<<20)

int N;
int x[MAX_N], y[MAX_N], z[MAX_N], m[MAX_N];

bool input(){
  cin>>N;
  int a[3];
  REP(i, N) {
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    x[i] = a[0];
    y[i] = a[1];
    z[i] = a[2];
    m[i] = x[i]*y[i]*z[i];
  }
  return N!=0;
}

#define MAX_V 204
struct edge { int to, cap, cost, rev; };
int V; // ????????°
vector<edge> G[MAX_V]; // ??°???????????£??\???????????¨???
int dist[MAX_V]; // ???????????¢
int prevv[MAX_V], preve[MAX_V]; // ??´??????????????¨???
// from??????to??????????????????cap????????????cost???????????°?????????????????????
void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
    G[to].push_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}
// s??????t????????????f???????°??????¨???????±???????
// ??????????????´??????-1?????????
int min_cost_flow(int s, int t, int f) {

    int res = 0;
    while (f > 0) {
        // ???????????????????????????????????????s-t????????????????±???????
        fill(dist, dist + V, INF);
        dist[s] = 0;
        bool update = true;
        while (update) {
            update = false;
            for (int v = 0; v < V; v++) {
                if (dist[v] == INF) continue;
                for (int i = 0; i < G[v].size(); i++) {
                    edge &e = G[v][i];
                    if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        update = true;
                    }
                }
            }
        }
        if (dist[t] == INF) {
            // ????????\???????????????
            return -1;
        }
        // s-t????????????????????£??????????????????
        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * dist[t];
        for (int v = t; v != s; v = prevv[v]) {
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

void resetG(int ver){
  V = ver;
  REP(i,V)G[i].clear();//while(!G[i].empty()) G[i].pop_back();
//  REP(i,V){preve[i] = 0;prevv[i] = 0;}
}

void solve(){
 resetG(N * 2 + 2);
 REP(i,N){
   REP(j,N){
     if(i == j)
       continue;
     if(x[i] > x[j] && y[i] > y[j] && z[i] > z[j])
       add_edge(j,i + N, 1, 0);
   }
   add_edge(V-2, i, 1, 0);
   add_edge(i+N, V-1, 1, 0);
   add_edge(i, V-1, 1, m[i]);
 }
 cout<<min_cost_flow(V-2, V-1,N)<<endl;
}

int main(){
  cin.tie(0);

  while (input()){
    solve();
  }

  return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int h,a;
    cin >> h >> a;
    if (h%a == 0) PRINT(h/a);
    else PRINT(h/a+1);
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n, 0);
  vector<int> c(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  int cost = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] > c[i]) {
      cost += (v[i] - c[i]);
    }
  }
  cout << cost;
  return 0;
}

Measured memory_bytes: 256