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

using namespace std;
typedef long long ll;

void solve(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        ans += (n - 1) / i;
    cout << ans << "\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
    return 0;
}

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

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

  int count=0;

  if (N<=1) count+=0;
  else count=count+N*(N-1)/2;

  if (M<=1) count+=0;
  else count=count+M*(M-1)/2;

  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 初期化
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int C = Integer.parseInt(data[2]);
		String[] B = sc.nextLine().split(" ");
		int value=0;
		int result=0;
		String line = "";
		
		for(int i=0;i<N;i++) {
			value=0;
			String[] A = sc.nextLine().split(" ");
			for(int j=0;j<M;j++) {
				value += Integer.parseInt(A[j]) * Integer.parseInt(B[j]);
			}
			if(value + C > 0) result++;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out






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

int n,m;
while(cin>>n){
    cin >> m;
    if(m == 0){
        break;
    }
    int b=0,ans=0;

int a[n];
int c = 0;
rep(i,n){
    cin >> a[i];
}

for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
      b = (a[i]+a[j]);
      if(m>=b){
         ans = max(b,ans);
            
          
          
          
      }
      

  }
}
       if(ans==0){
              cout << "NONE" << endl;}
       else{
           cout << ans << endl;
       }

}

///////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3184
#include<stdio.h>
int main(){
	char ch[1001];
	int i = 0,count,count2=0;
	scanf("%s",ch);
	while(ch[i]!='\0'){
		i++; 
	}
	//????????°????\???°???
	if((i%2)==1){
		for(int x = 0;x < i;x++){
			count = 0;
			if(ch[x] != '\0'){
				for(int y = i-1;y >=x;y--){
					if(ch[x] == ch[y]){
						ch[y] = '\0';
						count++;
					}
				}
			}
			if((count % 2) == 1){
				count2++;
			}
		}
		if((count2 % 2) == 1){
			printf("%d\n",count2/2);
		}
		else{
			printf("%d\n",(count2/2)+1);
		}
	}
	//????????°?????¶??°???
	else{
		for(int x = 0;x < i;x++){
			count = 0;
			if(ch[x] != '\0'){
				for(int y = i-1;y >=x;y--){
					if(ch[x] == ch[y]){
						ch[y] = '\0';
						count++;
					}
				}
			}
			if((count % 2) == 1){
				count2++;
			}
		}
		if((count2 % 2) == 1){
			printf("%d\n",(count2/2)+1);
		}
		else{
			printf("%d\n",count2/2);
		}
	}
	return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
#define All(a) a.begin(), a.end()
typedef pair<long long, long long> P;
int main(){
    string S, T;
    cin >> S >> T;
    T = T.substr(0, T.size() - 1);
    if(S == T){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
char a[55][55],b[55][55];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=m;j++){
			cin>>b[i][j];
		} 
	}
	for(int i=1;i<=n;i++) 
		for(int j=1;j<=n;j++){
			int cnt=0,s=0,x=1,y=1;
			for(int k=i;k<=n&&s<m*m;k++){
				for(int l=j;l<=n&&s<m*m;l++){
					s++;
					if(a[k][l]==b[x][y]) cnt++;
					//printf("(%d,%d),%d\n",k,l,cnt);
					y++;
					if(y==m+1) x++,y=1;
					if(l<=n&&l==j+m-1) break; 
					//printf("(%d,%d),%d\n",k,l,cnt);
				}
			}
			if(cnt==m*m) return  puts("Yes"),0;
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}

Measured memory_bytes: 256
# 方針：黒く塗られるべきマスの隣（縦or横）に、同様のマスがあれば塗れる→Yes
# 逆に、黒く塗られるべきマスに接していない、黒く塗られるべきマスがあると、達成は不可能→No

# 行数・列数の入力(Row, Column)
R, C = list(map(int, input().split(" ")))
# print(R, C)

# Want map = 設計図、Can map = 塗れるかのマップ
want_map = []
can_map = []

for r in range(R):
    # 一行ずつ、両マップを更新
    want_map.append(list(input()))
    can_map.append(["?"] * C)
#    print("Want Map: {}".format(want_map))

    for c in range(C):
        if can_map[r][c] != "feasible":
            if want_map[r][c] == ".":
                can_map[r][c] = "feasible"

            else:
                if c + 1 < C:
                    if want_map[r][c+1] == "#":
                        can_map[r][c] = "feasible"
                        can_map[r][c+1] = "feasible"
        else:
            if c + 1 < C:
                if want_map[r][c + 1] == "#":
                    can_map[r][c + 1] = "feasible"

        if r != 0:
            if (want_map[r][c] == "#") & (want_map[r-1][c] == "#"):
                can_map[r][c] = "feasible"
                can_map[r-1][c] = "feasible"

#    print("Can Map: {}".format(can_map))


# can_mapの中に"?"が残っていたらNo, なければYes
can_elements = []

for can_map_row in can_map:
    can_elements.extend(can_map_row)

if "?" in can_elements:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;

    int len = s.size(), ans = INF;
    for(int i=0; i<len-2; i++) {
        string t = s.substr(i, 3);
        int val = stoi(t);
        ans = min(ans, abs(753 - val));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


int main(){
	string s;
	cin >> s;
	int n = s.size();

	char base = s[n / 2];
	int cnt = 0;
	if (n % 2 != 0) {
		while (n / 2 - cnt >= 0 && n / 2 + cnt <= n-1) {
			if (s[n / 2 - cnt] == base && s[n / 2 + cnt]==base) {
				cnt++;
			}
			else {
				break;
			}
		}
		cout << n / 2 + cnt << endl;
	}
	else {
		while ((n / 2 - 1) - cnt >= 0 && n / 2 + cnt <= n-1) {
			if (s[(n / 2 - 1) - cnt] == base && s[n / 2 + cnt] == base) {
				cnt++;
			}
			else {
				break;
			}
		}
		cout << n / 2 + cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define dump(x) cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

int N, x;
int a[MAX];
int dp[MAX];
int b[MAX];

/*int ans(int depth) {
    if (depth == N) return 0;
    if (depth == N - 1) {
        return max(0, x - a[depth - 1] - a[depth]);
    }
    return min(
        ans(depth + 1) + max(0, x - b[depth] - a[depth]),
        ans(depth) + 2
        );
}
*/
void solve() {
    cin >> N >> x;
    rep(i, N) cin >> a[i];
    int res = 0;
    rep2(i, 1, N) {
        int v = a[i-1] + a[i] - x;
        if (v < 0) continue;
        res += v;
        int tmp = a[i];
        if (v < a[i]) {
            a[i] -= v;
        }
        else {
            a[i] = 0;
            a[i-1] -= v - tmp;
        }
    }
    cout << res << endl;
}


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

int main(void){
	long int n,k;

	scanf("%ld %ld\n",&n,&k);
	if(n%k==0){
		printf("0");
	}else{
		if(n>k/2){
			n=n%k;
		}
		if(n>k/2){
			n=k-n;
		}
		printf("%ld",n);
	}
	return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,i,a[87];
	cin>>n;
	a[0]=2;
	a[1]=1;
	for (i=2;i<87;i++){
		a[i]=a[i-1]+a[i-2];
	} 
	cout<<a[n];
	return 0;
}

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

int main(){
    int S;
    cin >> S;
    
    int YY = S/100;
    int MM = S - YY * 100;
    if(YY>=1&&YY<=12){
        if(MM>=1&&MM<=12){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else{
        if(MM>=1&&MM<=12){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, m;
int main()
{
    cin >> n >> m;
    if(n == 1 && m == 1)
    {
        cout << 1;
        return 0;
    }
    if(n == 1)
    {
        cout << m - 2;
        return 0;
    }
    if(m == 1)
    {
        cout << n - 2;
        return 0;
    }
    cout << 1LL * (n - 2) * (m - 2);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }

map<ll, ll> yaku_factor(ll N) {
	map<ll, ll> ret;
	ret[1] = 1;

	for (ll i = 2; i * i <= N; i++) {
		if (N % i == 0) {
			ret[i]=1;
			if (i != N / i) {
				ret[N / i] = 1;
			}
		}
	}
	if (N != 1)ret[N] = 1;
	return ret;

}

bool can_value(vector<ll> A, ll K) {
	vector<vector<bool> > DP(A.size() + 1, vector<bool>(K+1, false));
	DP[0][0] = true;


	rep(i, A.size()) {
		rep(k, K) {
			DP[i + 1][k] = DP[i+1][k] | DP[i][k];
			if(k >= A[i]) DP[i + 1][k] = DP[i+1][k] | DP[i][k-A[i]];
		}
	}

	return DP[A.size()][K];
}

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

	ll N, K;
	cin >> N >> K;

	vl A(N);
	rep(i, N) {
		cin >> A[i];
	}

	//sort(A.begin(), A.end());
	ll sum = 0;
	rep(i, N) {
		sum += A[i];
	}

	map<ll,ll> s_y = yaku_factor(sum);
	vl U(N), D(N), C(N);
	ll out = 0;
	ll l, r;


	for (auto itr = s_y.rbegin(); itr != s_y.rend(); itr++) {
		l = r = 0;
		bool flg = false;
		out = itr->first;
		rep(i, N) {
			U[i] = A[i] % out;
			r += out - U[i];
		}
		sort(U.begin(), U.end());

		rep(i, N-1) {
			l += U[i];
			r -= out - U[i];
			if (l == r){
				flg = true;
				break;
			}
		}

		if (flg && max(l, r) <= K)break;
	}


	cout << out << endl;



	return 0;
}



Measured memory_bytes: 384
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int dp[2019][2];
int main(){
	fastio;
	string s;
	int n;
	cin>>s;
	n=s.length();
	int now=0,prev=1;
	LL res=0;
	rep(i,n)
	{
		rep(j,2019){
			dp[((j*10)+(s[i]^48))%2019][now]+=dp[j][prev];
			dp[j][prev]=0;
		}
		dp[(s[i]^48)][now]++;
		res+=dp[0][now];
		swap(now,prev);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int n;
    cin >> n;
    cout << n * n * n << endl;


    return 0;
}

Measured memory_bytes: 3628
N,M=map(int,input().split())
n,m=N,M
s=input()
t=input()
while m:
  n,m=m,n%m
gcd=n
lcm=N*M//gcd
step1=N//gcd
step2=M//gcd
if all(s[i*step1]==t[i*step2] for i in range(gcd)):
  print(lcm)
else:
  print(-1)

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

int main() {
	int l, r, x;
	cin >> l >> r >> x;

	int ret = 0;
	for (int i = l; i <= r; ++i) {
		if (i % x == 0) {
			++ret;
		}
	}
	cout << ret << endl;


	return 0;
}

Measured memory_bytes: 3620
s=input()
t=input()
N,M=len(s),len(t)
dp=[[0]*(M+1) for i in range(N+1)]
dp2=[[0]*(M+1) for i in range(N+1)]
for i in range(N):
    for j in range(M):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
            dp2[i+1][j+1]=3
        elif dp[i][j+1]<dp[i+1][j]:
            dp[i+1][j+1]=dp[i+1][j]
            dp2[i+1][j+1]=1
        else:
            dp[i+1][j+1]=dp[i][j+1]
            dp2[i+1][j+1]=2
a=[]
while i>=0 and j>=0:
    if dp2[i+1][j+1]==1:
        j-=1
    elif dp2[i+1][j+1]==2:
        i-=1
    else:
        a.append(s[i])
        i-=1
        j-=1
print(*reversed(a),sep='')

Measured memory_bytes: 175624
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }

  vector<pair<int, int>> d;
  for (int i = 0; i < m; i++) {
    int b, c;
    cin >> b >> c;
    d.push_back(make_pair(b, c));
  }

  sort(a.begin(), a.end());
  sort(d.begin(), d.end(),
       [](const pair<int, int> &a, const pair<int, int> &b) {
         return a.second > b.second;
       });

  vector<int> chenges;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < d[i].first; j++) {
      chenges.push_back(d[i].second);
      if (chenges.size() == n)
        break;
    }
    if (chenges.size() == n)
      break;
  }

  int p = -1;
  for (int i = 0; i < chenges.size(); i++) {
    if (chenges[i] < a[i])
      break;
    else
      p = i;
  }

  for (int i = 0; i <= p; i++) {
    a[i] = chenges[i];
  }

  cout << accumulate(a.begin(), a.end(), 0LL) << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int Alice_score=0;
  int Bob_score=0;
  
  sort(A.begin(), A.end());
  reverse(A.begin(),A.end());
  
  for (int i=0; i<A.size(); i++){
    if (i%2==0){
      Alice_score = Alice_score + A.at(i);
    }
    else {
      Bob_score = Bob_score + A.at(i);
    }
  }
  cout << Alice_score-Bob_score;
}
    
  
  

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    map<ll,ll> m;
    rep(i,0,n){
        cin >> a[i];
        if(m.count(i-a[i]) == 0){
            m[i-a[i]] = 1;
        }
        else{
            m[i-a[i]]++;
        }
    }

    ll ans = 0;
    rep(i,0,n){
        if(m.count(i+a[i])) ans += m[i+a[i]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16548
#include <bits/stdc++.h>
#define ms(x, a) memset(x, a, sizeof(x))
#define oo 100000000
#define ll long long int
#define MOD 1000000007
using namespace std;
int main()
{
    ll h,a;
    cin>>h>>a;
    ll  sum =0;
    while(a--){
        ll b;
         cin>>b;
         sum+=b;
    }
    (h>sum)?cout<<"No":cout<<"Yes";
    return 0;
}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    while(true) {
        int N;
        std::cin >> N;
        if(N == 0) break;

        vector<string> S(N);
        REP(i, N) {
            std::cin >> S[i];
        }

        REP(i, N) {
            int tmp_i = i;
            auto f = [&](int num) {
                         int cnt = 0;
                         while(cnt < num) {
                             cnt += S[tmp_i].size();
                             tmp_i++;
                         }
                         return cnt != num ? false : true;
                     };
            if(f(5) && f(7) && f(5) && f(7) && f(7)) {
                std::cout << i + 1 << std::endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3208
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    dic = collections.defaultdict(int)
    ans = 0
    for _ in range(n):
        a = I()
        dic[a] += 1
    for key,value in dic.items():
        if value%2 == 1:
            ans += 1
    print(ans)
main()            


Measured memory_bytes: 84328
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    int answer = 0;

    cin >> N >> K;
    
    answer = K;
    for (int i = 1; i < N; i++)
    {
        answer *= K - 1;
    }
    
    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

func parseProblem() int {
	return scanInt(sc)
}

type restaurant struct {
	id, p int
	s     string
}
type restaurants []restaurant

func (r restaurants) Len() int {
	return len(r)
}

func (r restaurants) Less(i, j int) bool {
	l := ([]restaurant)(r)
	if l[i].s == l[j].s {
		return l[i].p > l[j].p
	}
	return l[i].s < l[j].s
}

func (r restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func resolve(n int) {
	ts := []restaurant{}
	for i := 1; i <= n; i++ {
		r := restaurant{
			id: i,
			s:  scanString(sc),
			p:  scanInt(sc),
		}
		ts = append(ts, r)
	}
	sort.Sort(restaurants(ts))
	for i := range ts {
		fmt.Println(ts[i].id)
	}
	return
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

void swap( int , int , int , int , int* );
void check( int* );


int main(void){
    // Your code here!
    int dice[6];
    int *p;
    int cnt,i,j,k,idx,n1,n2;
    p = dice;
    char flg;
    
    char t[6][10] = {"","N","W","E","S","NN"};
    
    for( int i = 0 ; i < 6 ; i++ ){
        scanf( "%d" , p + i );
    }
    
    scanf( "%d" , &cnt );
    
    for( i = 0 ; i < cnt ; i++ ){//大枠
    
        scanf( "%d %d" , &n1 , &n2 );
        for( j = 0 ; j < 6; j++ ){
        //printf("<--%d %d-->" , dice[j],n1 );
            if( dice[j] == n1 ){
                idx = j;
                break;
            }
        }
        for( k = 0 ; t[idx][k] != '\0' ; k++ ){
            flg = t[idx][k];
            switch( flg ){
                case 'N'://1 -> 5 / 5 -> 6 / 6 -> 2 / 2 -> 1 // 1と5 → 1と2 → 2と6
                    swap( 0 , 1 , 5 , 4 , p );
                    break;
                case 'S':
                    swap( 0 , 4 , 5 , 1 , p );
                    break;
                case 'E':
                    swap( 0 , 3 , 5, 2 , p );
                    break;
                case 'W':
                    swap( 0 , 2 , 5 , 3 , p );
                    break;
                default:
                    break;
            }
        }
        
        
        while( dice[1] != n2 ){
            swap( 1 , 2 , 4 , 3 ,p );
        }

        //check( dice );        
        printf( "%d\n" , dice[2] );
    }
}



void swap( int x1, int x2 , int x3 , int x4 , int *dice ){
    
    int tmp;
    tmp = *( dice + x1 );
    *( dice + x1 ) = *( dice + x2 );
    *( dice + x2 ) = *( dice + x3 );
    *( dice + x3 ) = *( dice + x4 );
    *( dice + x4 ) = tmp;
    return;
};

void check(int *dice){
    for( int i = 0 ; i < 6 ; i++ ){
        printf( "%d " , dice[i] );
    }
    printf("\n");
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n; cin >> n;
	vector<int> a(n+1);
	for (int i=1;i<=n;i++){
		cin >> a[i];	
	}

	int t = 1;
	int ans = 999999999;
	while (t != n){
		int sum = 0;
		int sum2 = 0;
		for (int i = 1; i<=t; i++){
			sum+=a[i];
		}
		
		for (int i = t+1; i <= n; i++){
			sum2+=a[i];
		}

		ans = min(ans, abs(sum-sum2));
		t++;
	}

	cout << ans << "\n";

    return 0;
}


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

int main(){
    long long n;
    cin >> n;
    for(long long i=1;i<=3500;i++){
        for(long long j=1;j<=3500;j++){
            long long ww=4*i*j-n*i-n*j;
            if(ww!=0&&(n*i*j)%ww==0){
                long long w=(n*i*j)/ww;
                if(w>0){
                    cout << i << " " << j << " " << w << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define pbb pop_back
#define make_pair mp
#define all(x) x.begin(), x.end()
#define mem(array, value) memset(array, value, sizeof(array))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a,b))*b
#define line cout << "==========" << endl
#define mod 1000000007
#define SIZE 1000001
bool prime[60000];
void gen_prime(int n)
{
    int sqrtN = sqrt(n);
    for (int i = 3; i<sqrtN; i+=2){
        for (int j = i*i; j<=n; j+=i+i)
            prime[j] = 1;
    }
}
int main ()
{
    gen_prime(55559);
    int n;
    cin >> n;
    for (int i = 3; ; i+=2){
        if (!prime[i] && i%5 == 1){
            cout << i << " ";
            n--;
        }
        if (n == 0)
            break;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
    while($line = trim(fgets(STDIN))){
        $tmp = explode(" ",$line);
        switch($tmp[1]){
            case "+" : 
                print($tmp[0] + $tmp[2] . "\n");
                break;
            case "-" : 
                print($tmp[0] - $tmp[2] . "\n");
                break;
            case "*" : 
                print($tmp[0] * $tmp[2] . "\n");
                break;
            case "/" :
                print(floor($tmp[0] / $tmp[2]) . "\n");
                break;
            default : break;
        } 
    }


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

using namespace std;

int main()
{
    int a,b,c; int d,e;
    int x,y; int ans=0;

    cin>>a>>b>>c>>x>>y;

    d=2*c;
    e=a+b;

    int m;
    m=min(x,y);
    ans=m*min(d,e)+(x-m)*min(d,a)+(y-m)*min(d,b);

    cout<<ans;

    return 0;
}

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

int main() {
  int a,b,x,y ;
  cin>>a>>b ;
  x=a%2,y=b%2;
  if (x==1 && y==1){
  	cout<<"Odd"<<endl;}
  else{
  	cout<<"Even"<<endl;}
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.next().split("");
        
        Map<String, Integer> map = new HashMap<>();
        for (String s : str) {
            if (map.containsKey(s)) {
                map.put(s, map.get(s)+1);
            } else {
                map.put(s, 1);
            }
        }

        int result = 700;
        if (map.containsKey("o")) result += (100*map.get("o"));
        System.out.println(result);
    }
}


Measured memory_bytes: 35432
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
q=[0,0,0]
for x in p:
    if x<=a: q[0]+=1
    elif x>a and x<=b: q[1]+=1
    else: q[2]+=1

print(min(q))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

const ll N = 11;
ll dp[N][N];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll k;
	cin >> k;
	for(ll i = 1; i < N; i++){
		for(ll j = 0; j < 10; j++){
			if(i == 1)
				dp[i][j] = 1;
			else
				dp[i][j] += (j - 1 >= 0 ? dp[i - 1][j - 1] : 0) + dp[i - 1][j] + (j + 1 < 10 ? dp[i - 1][j + 1] : 0);
		}
	}
	ll ans = 0;
	for(ll i = 1; i < N; i++){
		for(ll j = 1; j < 10; j++){
			if(dp[i][j] < k)
				k -= dp[i][j];
			else{
				ans = ans * 10 + j;
				ll prev = j;
				for(ll k1 = i - 1; k1 >= 1; k1--){
					for(ll k2 = 0; k2 < 10; k2++){
						if(abs(k2 - prev) <= 1){
							if(dp[k1][k2] < k)
								k -= dp[k1][k2];
							else {
								ans = ans * 10 + k2;
								prev = k2;
								break;
							}
						}
					}
				}
				break;
			}
		}
		if(ans > 0)
			break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = (a); i <= (n); i++)
#define INF 100000000
using namespace std;

const int M = 1000000;
int N, dp1[M + 1], dp2[M + 1];

int main(void) {
  REP(i, 1, M) dp1[i] = dp2[i] = i;

  for(int i = 1, n; n = i * (i + 1) * (i + 2) / 6, n <= M; i++) {
    dp1[n] = 1;
    if(n % 2 == 1) dp2[n] = 1;
    for(int j = 1; j + n <= M; j++) {
      dp1[j + n] = min(dp1[j + n], dp1[j] + 1);
      if(n % 2 == 1) {
        dp2[j + n] = min(dp2[j + n], dp2[j] + 1);
      }
    }
  }

  while(cin >> N, N) {
    cout << dp1[N] << " " << dp2[N] << endl;
  }

  return 0;
}

Measured memory_bytes: 10884
// Problem: C - Sum of product of pairs
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define FAST_IO                                                                                                        \
    ios::sync_with_stdio(0);                                                                                           \
    cin.tie(0);                                                                                                        \
    cout.tie(0);
#define ll long long int
#define mp make_pair
#define pb push_back
#define p pair
#define vt vector
#define F first
#define S second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
#define endl "\n"
#define db1(x) cout << #x << " = " << x << '\n';
#define db2(v)                                                                                                         \
    for (auto &x : v)                                                                                                  \
        cout << x << " ";
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
using namespace std;

int main()
{
    FAST_IO;
    int n;
    cin >> n;
    vt<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll ans = 0, sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
        sum = sum % MOD;
    }
    for (int i = 0; i < n - 1; i++)
    {
        sum -= a[i];
        if (sum < 0)
        {
            sum += MOD;
        }
        ans += a[i] * sum;
        ans = ans % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4776
k = gets.to_i

2.upto(50) do |n|
  # 引く N の割り振り
  ha = k / n # 一人あたり
  am = k % n # あまり

  ret = Array.new(n) { |ix|
          gentime = (ha + (ix < am ? 1 : 0))
          (n - 1) + (gentime * n) - (k - gentime)
        }

  if ret.all? { |v| 0 <= v && v <= 10**16 + 1000 }
    puts n
    puts ret.join(' ')
    exit
  end
end


Measured memory_bytes: 1788
import sys


def solve(inp):
    (X, A, B) = map(int, inp.readline().strip().split(' '))

    if abs(X - A) < abs(X - B):
        return "A"
    else:
        return "B"


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


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

#define FOR(i,s,e) for(int i=s;i<e;i++)
#define RFOR(i,s,e) for(int i=s;i>=e;i--)

// vector<int> vec(N,0) →長さN,0初期化
// vec[i]→ iにアクセス、vec.push_back(x)　→末尾にxを追加
// vec.size()サイズ取得
// vec2d[20][10] == vector< vector<int> > v2d(N, vector<int>(3,0))
#define SORT(vec) sort(vec.begin(),vec.end())
#define MAX(vec) *max_element(vec.begin(),vec.end())
#define MAXID(vec) distance(vec.begin(),max_element(vec.begin(),vec.end()))
#define MIN(vec) *min_element(vec.begin(),vec.end())
#define MINID(vec) distance(vec.begin(),min_element(vec.begin(),vec.end()))
#define NID(vec,n) distance(vec.begin(),find(vec.begin(),vec.end(),n))



int N;


int main(){
	cin >> N;

	if(N == 1) {
		cout << "Hello World" << endl;
	}else{
		int A,B;
		cin >> A;
		cin >> B;
	 	cout << A + B << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 double N,M;
 cin>>N>>M;
 double p=pow(2,M);
 cout<<p*(1900*M+(N-M)*100)<<endl;
 return 0;
}

Measured memory_bytes: 4176
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll n,m;
  cin >> n>>m;
  if(n==1&&m==1) cout <<1<<endl;
  else if(n==1||m==1) cout <<n*m-2<<endl;
  else cout <<n*m-(n*2+(m-2)*2)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
ll dp[110000];
bool vis[110000];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    while(m--){
        int x;scanf("%d",&x);   vis[x]=true;
    }
    dp[0]=0;    dp[1]=1;    dp[2]=2;
    if(vis[1])  dp[1]=0,dp[2]=1;
    if(vis[2])  dp[2]=0;
    for(int i=3;i<=n;i++){
        if(vis[i])   continue;
        dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 1152
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}
	sort.Ints(l)
	sum := 0
	for i := 0; i < k; i++ {
		sum += l[n-1-i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
k = int(input())
l = list(map(int, input().split()))
flag = True
for i in range(k):
    if l[i]%2 == 0 and l[i] % 3 != 0 and l[i] % 5 != 0:
        flag = False
        break

if flag:
    print('APPROVED')
else:
    print('DENIED')







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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    sum += B[i];
  }
  vector<int> C(N-1);
  for (int i = 0; i < N-1; i++) cin >> C[i];
  for (int i = 0; i < N-1; i++) {
    if (A[i]+1 == A[i+1]) sum += C[A[i]-1];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
using namespace std;

typedef struct{
	string name;
	double eff;
}vegetable;

int main(){
	while(1){
		int n;
		vegetable v[50];
		
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			cin >> v[i].name;
			int p,a,b,c,d,e,f,s,m;	
			
			cin>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			int time=a+b+c;
			for(int j=0; j<m; ++j) time+=d+e;
			long price=m*f*s;
			price-=p;
			v[i].eff = (double)price/time;
		}
		
		for(int i=0; i<n; ++i){
			for(int j=i; j<n; ++j){
				if(v[i].eff < v[j].eff) swap(v[i], v[j]);
				else if(v[i].eff == v[j].eff){
					if(v[i].name > v[j].name) swap(v[i], v[j]);	
				}
			}
		}
		
		for(int i=0; i<n; ++i) cout << v[i].name << endl;
		printf("#\n");
	}
	return 0;
}

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

long long dp[5010];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, p; cin >> n; p = n / 2;
    long long mod; cin >> mod;
    dp[0] = 1;
    if (n & 1) {
        for (int i = 0; i * (p+1) < n; i++) dp[i*(p+1)] = 1;
    }
    for (int i = 1; i <= p; i++) {
        vector<long long> sum(i, 0);
        for (int j = 0; j < n; j++) {
            sum[j%i] += dp[j];
            dp[j] += sum[j%i] - dp[j];
            if (j / i) dp[j] += dp[j-i];
            dp[j] %= mod;
            sum[j%i] %= mod;
        }
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + dp[i]) % mod;
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,ll> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}
const ll INF = 1LL<<60;


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, s;
	cin >>n >>m >>s;
	int MX = (n+1)*51;
	s = min(MX, s);
	vector<VI> z1(n, VI(n)), z2(n, VI(n));
	vector<VI> rr(n);
	rep(i, m){
		int u, v, az,b;
		cin >>u >>v >>az >>b;
		u--; v--;
		z1[u][v] = z1[v][u] = az;
		z2[u][v] = z2[v][u] = b;
		rr[u].emplace_back(v);
		rr[v].emplace_back(u);
		
	}
	VI w1(n), w2(n);
	rep(i, n){
		int g, d; cin >>g >>d;
		w1[i]=g; w2[i] = d;
	}
	
	VL ans(n, INF);
	typedef tuple<ll, int, int> TL;
	priority_queue< TL, vector<TL>, greater<TL> > que;
	vector<VL> dp(n, VL(MX+3, INF));
	dp[0][s] = 0; ans[0]=0;
	que.emplace(0, 0, s);
	while(!que.empty()){
		ll c0, v, c2;
		tie(c0, v, c2) = que.top(); que.pop();
		if(dp[v][c2] < c0) continue;
		for(auto q2 : rr[v]){
			if(c2 >= z1[v][q2]){
				ll ncst = dp[v][c2] + z2[v][q2];
				if( ncst < dp[q2][c2-z1[v][q2]]){
					dp[q2][c2-z1[v][q2]] = ncst;
					que.emplace(ncst, q2, c2-z1[v][q2]);
					ans[q2] = min(ans[q2], ncst);
				}
			}
		}
		if(c2 < MX ){
			int zxc = min<ll>(MX, c2+w1[v]);
			ll ncst = dp[v][c2] + w2[v];
			if(dp[v][zxc]  > ncst){
				dp[v][zxc] = ncst;
				que.emplace(ncst, v, zxc);
			}
		}
	}
	rep2(i,1, n) cout << ans[i] <<"\n";
	return 0;
}


Measured memory_bytes: 6360
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
const int P=2019;
string s;
int cnt[2025],cur,ans,base=1;
int main()
{
    cin>>s;
    cnt[0]=1;
    for(int i=s.size()-1;i>=0;i--){
        cur=((s[i]-'0')*base%P+cur)%P;
        base=base*10%P;
        ans+=cnt[cur];
        cnt[cur]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3748
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;


public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int[] ar;
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	static long dp[][];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
		
			int n=sc.nextInt();
			ar=new int[n];
			long sum=0;
			for(int i=0;i<n;i++) {
				ar[i]=sc.nextInt();
				sum+=ar[i];
			}
			dp=new long[n][n];
			long ans=solve(0,n-1);
			long ans1=sum-ans;
			
			System.out.println(ans-ans1);
			
		}

		System.out.println(out);
	}
	static long solve(int i,int j) {
		if(i==j)return ar[i];
		if(i+1==j)return Math.max(ar[i], ar[j]);
		if(dp[i][j]!=0)return dp[i][j];
		long ans=0;
		long ans1=ar[i]+Math.min(solve(i+2,j), solve(i+1,j-1));
		long ans2=ar[j]+Math.min(solve(i,j-2), solve(i+1,j-1));
		ans=Math.max(ans1, ans2);
		
		return dp[i][j]=ans;
		
	}


}


Measured memory_bytes: 128448
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  ll X, now = 100, ans = 0;
  cin >> X;
  
  while(now < X){
    ans++;
    now += floor(now * 0.01);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
if __name__ == "__main__":
    modulus = 10 ** 9 + 7
    s = input()
    n = len(s)
    dp = [[0] * 4 for _ in range(n + 1)]

    for i in range(n + 1)[::-1]:
        for j in range(4)[::-1]:
            if i == n:
                if j == 3:
                    dp[i][j] = 1
                else:
                    dp[i][j] = 0
            else:
                is_wildcard = s[i] == '?'
                if j == 3:
                    m = 3 if is_wildcard else 1
                    dp[i][j] = m * dp[i + 1][3] % modulus

                else:
                    m1 = 3 if is_wildcard else 1
                    m2 = 1 if is_wildcard or s[i] == 'ABC'[j] else 0

                    dp[i][j] = (m1 * dp[i + 1][j] + m2 * dp[i + 1][j + 1]) % modulus
            # print(i, j, dp[i][j])
    print(dp[0][0])


Measured memory_bytes: 27588