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

using namespace std;

const int INFINI = 1e18;

int32_t main()
{
    int n,c;
    cin >> n >> c;

    int v[n], w[n];

    int vMax = 1e5+42;

    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    int dp[n+1][vMax+1];

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= vMax; j++) {
            dp[i][j] = INFINI;
        }
    }

    for(int i = 0; i <= n; i++) dp[i][0] = 0;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= vMax; j++) {
            if(j >= v[i-1]) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    int best = 0;

    for(int i = 0; i <= vMax; i++) {
        if(dp[n][i] <= c) best = max(best, i);
    }

    cout << best;

    return 0;
}


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



int main(){
    int N,M;
    cin >> N>>M;
    vector<pair<long long int,int>> pairs(N);
    long long int ans = 0;
    int numd = 0;
    
    for(int i = 0; i < N; i++){
        cin>>pairs[i].first>>pairs[i].second;
    }
    sort(pairs.begin(),pairs.end());



        for(int i = 0; i < N; i++){
            int remain = pairs[i].second;
            long long int temp = pairs[i].first*pairs[i].second;

            
            if(M - numd >=  pairs[i].second){
                ans += temp;
                numd += pairs[i].second;
                
                
            }else{
                while(remain > 0){
                    ans += pairs[i].first;
                    numd++;
                    remain--;
                    if(numd == M){
                        break;
                    }
               
                }
                
            }
            if(numd == M){
                break;
            }
            
        }
        cout << ans << endl;
    
        return 0;
    
}

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

using std::cin;
using std::cout;
using std::endl;

using std::min;
using std::max;

using std::vector;

int main(void) {
    int x, t;
    cin >> x >> t;
    int ans = max(0, x - t);
    cout << ans << endl;
    return 0;
}


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

ll mod = 1e9+7;

vector<vector<ll>> c;

ll comb(ll n, ll m){
    if(m > n-m) m = n - m;

    if(c[n][m] != -1) return c[n][m];
    if(m==0){
        c[n][m] = 1;
    }else{
        c[n][m] = (comb(n-1,m-1) + comb(n-1,m))%mod;
    }
    return c[n][m];
}

int main(){
    ll N, M;  cin >> N >> M;
    vector<ll> x;
    for(ll i=2; i*i<=M; i++){
        if(M%i==0){
            x.push_back((ll)0);
            while(M%i==0){
                x.back()++;
                M/=i;
            }
        }
    }
    if(M != 1) x.push_back((ll)1);

    ll Clen = 0;
    for(int i=0; i<x.size(); i++) Clen = max(Clen, x[i]);
    c = vector<vector<ll>>(N+Clen, vector<ll>(min(Clen, N-1) + 1, -1));

    ll ans = 1;
    for(int i=0; i<x.size(); i++){
        ans *= comb(N-1+x[i], x[i]);
        ans = ans%mod;
    }
    cout << ans << endl;
}


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

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define FS first
#define SE second

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//Greatest Common Devider
LL gcd(LL a,LL b){
  if(b == 0) return a;
  return gcd(b,a%b);
}
//------------------------------------------
//Least Common Multiple
//Must be used with GCD
LL lcm(LL a,LL b){
  LL g = gcd(a,b);
  return a / g * b;
}
//grobal var
//------------------------------------------


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  str S;
  cin >> S;
  bool ym=false,my=false;
  if(stoi(S.substr(0,2))<=12&&0<stoi(S.substr(0,2))) my=true;
  if(stoi(S.substr(2,2))<=12&&0<stoi(S.substr(2,2))) ym=true;
  str ans;
  if(ym&&my) ans = "AMBIGUOUS";
  else if(my) ans = "MMYY";
  else if(ym) ans = "YYMM";
  else ans = "NA";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main() {
	int a,b,m;
	cin >> a>>b>>m;

	int av[a + 1];
	int av2[a + 1];
	int bv[b + 1];
	int bv2[b + 1];
	for (int i = 1; i <= a; i++) {
		cin >> av[i];
		av2[i] = av[i];

	}
	for (int i = 1; i <= b; i++) {
		cin >> bv[i];
		bv2[i] = bv[i];
	}

	sort(av + 1, av + a + 1);
	sort(bv + 1, bv + b + 1);

	int ans = 10000000;
	ans = av[1] + bv[1];

	for(int i=1;i<=m;i++){
		int p, q,r;
		cin >> p >> q>>r;
		
			ans =min(ans, av2[p] + bv2[q]-r);
		}
	

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	int y = stoi(s.substr(0, 4));
	int m = stoi(s.substr(5, 2));
	int d = stoi(s.substr(8, 2));
	
	if (y <= 2018) cout << "Heisei";
	else if (y >= 2020) cout << "TBD";
	else cout << (5 <= m ? "TBD" : "Heisei") << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int m,n;
int s,t;
typedef pair<int,int> P;
typedef pair<P,int> PP;
const int INF=10000000;
int field[101][101];
int field2[101][101];
int x[11],y[11];
int nx[11],ny[11];
int dx1[6]={0,-1,0,1,1,1};
int dx2[6]={-1,-1,-1,0,1,0};
int dy[6]={-1,0,1,-1,0,1};

void bfs(int sx,int sy){
	queue<PP> que;
	que.push(PP(P(sx,sy),0));
	field[sx][sy]=0;
	while(que.size()){
		PP q=que.front();que.pop();
		int cx=q.first.first,cy=q.first.second;
		int c=q.second;
		for(int i=0;i<6;i++){
			int py=cy+dy[i];
			int px=cx;
			if(cy%2==0)px+=dx1[i];
			if(cy%2==1)px+=dx2[i];
			if(px>=1 && px<=m && py>=1 && py<=n && field[px][py]>c+1){
				field[px][py]=c+1;
				que.push(PP(P(px,py),c+1));
			}
		}
	}
}

int bfs2(int sx,int sy){
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			field2[i][j]=field[i][j];
		}
	}
	queue<PP> que;
	int res=1;
	if(field2[sx][sy]==0)return 0;
	field2[sx][sy]=0;
	que.push(PP(P(sx,sy),0));
	while(que.size()){
		PP q=que.front();que.pop();
		int cx=q.first.first,cy=q.first.second;
		int c=q.second;
		for(int i=0;i<6;i++){
			int py=cy+dy[i];
			int px=cx;
			if(cy%2==0)px+=dx1[i];
			if(cy%2==1)px+=dx2[i];
			if(px>=1 && px<=m && py>=1 && py<=n && field2[px][py]>c+1){
				res++;
				field2[px][py]=c+1;
				que.push(PP(P(px,py),c+1));
			}
		}
	}
	return res;
}

int main(void){
	while(1){
		int ans=0;
		for(int i=0;i<=100;i++){
			for(int j=0;j<=100;j++){
				field[i][j]=INF;
			}
		}
		cin >> m;
		if(m==0)break;
		cin >> n;
		cin >> s;
		for(int i=0;i<s;i++){
			cin >> x[i] >> y[i];
			bfs(x[i],y[i]);
		}
		cin >> t;
		for(int i=0;i<t;i++){
			cin >> nx[i] >> ny[i];
			ans=max(ans,bfs2(nx[i],ny[i]));
		}
		cout << ans << endl;
	}
    return 0;
}

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


int main(){
//A
/*
string s;
cin>>s;
if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
*/
//B
/*
ll X;cin>>X;
ll x;
x=X%500;
//cout<<X/500*1000<<endl;
//cout<<x<<endl;
cout<<X/500*1000+x/5*5<<endl;
*/
//C
/*
int k,n;
cin>>k>>n;
vector<int> a(n);
rep(i,0,n) cin>>a[i];
sort(a.begin(),a.end());
vector<int> b(n);
rep(i,0,n-1) b[i]=a[i+1]-a[i];
b[n-1]=a[0]+k-a[n-1];
sort(b.begin(),b.end());
cout<<k-b[n-1]<<endl;//外周ー最大間隔 
*/
//D
//E
int x,y,a,b,c;
cin>>x>>y>>a>>b>>c;
vector<ll> p(a),q(b),r(c);
rep(i,0,a) cin>>p[i];
rep(i,0,b) cin>>q[i];
rep(i,0,c) cin>>r[i];
sort(p.begin(),p.end());
reverse(p.begin(),p.end());
sort(q.begin(),q.end());
reverse(q.begin(),q.end());

/*c++の削除処理は末尾を除いて遅い
while(p.size()!=x) p.erase(p.begin());
while(q.size()!=y) q.erase(q.begin());
*/

priority_queue<ll> pq;
rep(i,0,x) pq.push(p[i]);
rep(i,0,y) pq.push(q[i]);
rep(i,0,c) pq.push(r[i]);

ll cnt=0;
rep(i,0,x+y){
cnt+=pq.top();
pq.pop();
}
cout<<cnt<<endl;
}

Measured memory_bytes: 8816
n = int(input())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))
cList = list(map(int, input().split()))
ans = sum(bList)
before = -2
for i in range(0, n):
    a = aList[i] - 1
    if before + 1 == a:
        ans = ans + cList[before]
    before = a

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    bool flag=false;
    for (int i=0;i<=100;i++)
      for (int j=0;j<=100-i;j++)
       {
      	 if (i*2+j*4==y&&i+j==x) 
      	   {
      	   	  flag=true;
      	   	  break;
      	   }
       }
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
} 

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

int main() {
	// your code goes here
	int a, cnt1=0, cnt2=0;
	
	for(int i=0; i<3; i++){
		cin >> a;
		if(a == 5) cnt1++;
		if(a == 7) cnt2++;
 	}
 	
 	if(cnt1 == 2 && cnt2 == 1) cout << "YES" << endl;
 	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N =2e5+100;
int main()
{
    int n,Min[N],x,res =0;
    scanf("%d",&n);
    Min[0] =0x3f3f3f3f;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        Min[i] =min(Min[i-1],x);
        if(x ==Min[i])
            res++;
    }

    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    if (S.size() == 2) cout << S << endl;
    else
    {
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
}


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

long long n, t;

struct shower {
	long long when;
	long long length;
};

long long currentTime = 0;

int main() {
	cin >> n >> t;
	long long rez = 0;
	shower s;
	s.when = 0;
	s.length = 0;
	for (long long i = 0; i < n; i++) {
		long long tmp;
		cin >> tmp;
		rez += min(s.length, tmp - s.when);
		//cout << "Now: " << s.length << ", " << tmp-s.when << endl;
		s.when = tmp;
		s.length = t;
	}
	rez += s.length;
	cout << rez;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
map<string, int> cache;
bool same(string seq){
  for(int i = 0; seq[i+1] != '\0'; ++i){
    if(seq[i] != seq[i+1]){
      return false;
    }
  }
  return true;
}
int dls(string seq, int depth){
  if(depth<0){
    return false;
  }
  if(same(seq)){
    return true;
  }
  if(cache.find(seq) != cache.end() && cache[seq] >= depth){
    return false;
  }
  else{
    cache[seq] = depth;
  }
  for(int i = 0; seq[i+1] != '\0'; ++i){
    char t = seq[i];
    char n = seq[i+1];
    if(t != n){
      if((t + n) == ('r' + 'b')){
        seq[i] = seq[i+1] = 'g';
      }
      else if((t + n) == ('r' + 'g')){
        seq[i] = seq[i+1] = 'b';
      }
      else{
        seq[i] = seq[i+1] = 'r';
      }
      if(dls(seq, depth-1)){
        return true;
      }
      seq[i] = t;
      seq[i+1] = n;
    }
  }
  return false;
}
void iddfs(string seq){
  cache = map<string, int>();
  for(int depth = 0;depth <= 20; ++depth){
    if(dls(seq, depth)){
      cout << depth << endl;
      return;
    }
  }
  cout << "NA" << endl;
}
int main(){
  char seq[11];
  while(true){
    cin >> seq;
    if(seq[0] == '0'){
      break;
    }
    iddfs(seq);
  }
  return 0;
}

Measured memory_bytes: 2496
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int a,b; cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b));

	return 0;
}


Measured memory_bytes: 256
def solve():
  ans = 0
  N = int(input())
  A = [float('inf')]+list(map(int, input().split()))+[-float('inf')]
  UD = [0]*(N+1)
  for i in range(N+1):
    if A[i]>A[i+1]:
      UD[i] = -1
    elif A[i]<A[i+1]:
      UD[i] = 1
    else:
      UD[i] = UD[i-1]
  UD2 = [0]*N
  for i in range(N):
    if UD[i]>UD[i+1]:
      UD2[i] = -1
    elif UD[i]<UD[i+1]:
      UD2[i] = 1
  stock = 0
  money = 1000
  if -1 not in UD2:
    ind = -1
  else:
    ind = (N-1)-UD2[::-1].index(-1)
  for i in range(N):
    if UD2[i]==-1:
      money += A[i+1]*stock
      stock = 0
      if i==ind:
        break
    elif UD2[i]==1:
      stock,money = divmod(money,A[i+1])
  return money
print(solve())

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

using namespace std;

#define rep(i,a,b) for(int i = int(a); i < int(b) ; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

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


int main(){
	
	int n, y; cin >> n >> y;
	y/=1000;
	
	for(int i=n; i>=0; i--){
		if(i*10 > y) continue;
		for(int j=n-i; j>=0; j--){
			if(i*10 + j*5 > y) continue;
			int k = n-j-i;
			if(i*10 + j*5 + k == y){
				cout << i << " " << j << " " << k << '\n';
				return 0;
			}
		}
	}
	
	puts("-1 -1 -1");
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <cmath>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

const int N=105;
const double dinf=1e10;

int n,m,pre[N],vis[N],cnt,ced[N],i,j,k;
double g[105][105],len[105];
double gra[105][105];

void dfs(int s)//dfs蛻、譏ッ蜷ヲ譛芽ァ」
{
    vis[s]=1;cnt++;
    for(int i=1;i<=n;i++)
        if(gra[s][i]<dinf&&!vis[i])
            dfs(i);
}

double ZHULIU(int s)
{
	clr(vis,0);cnt=0;
	dfs(s);if(cnt!=n)return -1;
    clr(ced,0);double ans=0;
    int i,j,k;//霑咎?逧?豈碑セ?・?束?檎ョ。莉門造
    do
	{
	    for(i=1;i<=n;i++)//貂?勁閾ェ邇ッ?御サ・蜿頑アよッ丈クェ轤ケ逧??霎ケ
	    {
	        if(ced[i]||i==s)continue;
	        pre[i]=1;
	        for(j=1;j<=n;j++)
                if(j!=s&&j!=i&&!ced[j]&&gra[pre[i]][i]>gra[j][i])
                    pre[i]=j;
	    }
	    pre[s]=s;
        for(i=1;i<=n;i++)
        {
            if(ced[i]||i==s)continue;
            clr(vis,0);
            for(j=i;j!=s&&!vis[j];j=pre[j])vis[j]=1;//蟇サ謇セ邇ッ?瑚「ォvis譬?ョー逧?弍邇ッ蜀?噪轤ケ
            if(j==s)continue;
            ans+=gra[pre[j]][j];
            for(i=pre[j];i!=j;i=pre[i])//謚顔識驥檎噪譚??蜉?芦ans荳ュ蜴サ
                ans+=gra[pre[i]][i],ced[i]=1;
            for(k=1;k<=n;k++)//霑吩クェ蜥御ク矩擇驍」荳ェfor蝨ィ郛ゥ轤ケ
                if(!ced[k]&&gra[k][j]<dinf)
                    gra[k][j]-=gra[pre[j]][j];
            for(i=pre[j];i!=j;i=pre[i])
                for(k=1;k<=n;k++)
                {
                    if(ced[k])continue;
                    gra[j][k]=min(gra[j][k],gra[i][k]);
                    if(gra[k][i]<dinf)
                        gra[k][j]=min(gra[k][j],gra[k][i]-gra[pre[i]][i]);
                }
            break;
        }
	}while(i<=n);
	for(int i=1;i<=n;i++)//謚贋ク肴弍蜑ゥ荳狗噪蜈・霎ケ驛ス蜉?ク?
        if(!ced[i]&&i!=s)ans+=gra[pre[i]][i];
	return ans;
}


int main(){
//    freopen("in.txt","r",stdin);
//    freopen("/home/axorb/in","r",stdin);
    scanf("%d%d",&m,&n);n++;
    for(i=2;i<=n;i++){
        for(j=1;j<=m;j++){
            scanf("%lf",&g[i][j]);
            len[i]+=g[i][j]*g[i][j];
        }
        len[i]=sqrt(len[i]);
        gra[1][i]=len[i]*len[i];
        gra[i][1]=dinf;
    }
    for(i=2;i<=n;i++){
        for(j=2;j<=n;j++){
            double tmp=0;
            if(i==j) gra[i][j]=dinf;
            for(k=1;k<=m;k++){
                tmp+=g[i][k]*g[j][k];
            }
            double ang=tmp/len[i]/len[j];
            ang=sqrt(1-ang*ang);
            gra[i][j]=(len[j]*ang)*(len[j]*ang);
        }
    }
    printf("%.10lf\n",ZHULIU(1));
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

Int n;
vector<Int> A;
Int used[111][10],mem[111][10];
Int dfs(Int idx,Int f,Int col){
  if(idx == n) return 0;
  if(used[idx][f]++) return mem[idx][f];
  Int a = INF, b = INF;
  a = 1 + dfs(idx+1, 1, col); //change
  if(f == 1 || col != A[idx])b = dfs(idx+1, 0, A[idx]);//not change
  
  Int res = min(a, b);
  return  mem[idx][f] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>n;
  A.resize(n);
  cin>>A;
  
  Int ans = dfs(0, 1, 0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ucin() ios :: sync_with_stdio(0)
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef double db;

const int N = 1e5 + 10;

int main() {
	ucin();
	int a, b;
	cin >> a >> b;
	cout << (1 <= a && a <= 9 && 1 <= b && b <= 9 ? a * b : -1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1000000007;
ll gyaku(ll n){
  ll y=mod-2;
  ll now=n;
  ll ret=1;
  while(y>0){
    if(y%2==1)ret*=now;
    now*=now;
    ret%=mod;
    now%=mod;
    y/=2;
  }
  return ret;
}
ll nck(ll n,ll k){
  if(2*k>n)k=n-k;
  ll ret=1;
  for(ll i=0;i<k;i++){
    ret*=n-i;
    ret%=mod;
    ret*=gyaku(i+1);
    ret%=mod;
  }
  return ret;
}
int main(){
  ll n;cin>>n;
  vector<pll> v;
  ll a[n],b[n];
  ll kai[100001];
  kai[0]=1;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    v.push_back(make_pair(a[i],(ll)0));
  }
  for(ll i=0;i<n;i++){
    cin>>b[i];
    v.push_back(make_pair(b[i],(ll)1));
  }
  sort(v.begin(),v.end());
  for(ll i=1;i<=100000;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  ll ans=1;
  ll c[2];
  c[0]=0;c[1]=0;
  for(ll i=0;i<v.size();i++){
    ll t=v[i].second;
    ll s=(t+1)%2;
    c[t]++;
    if(c[t]>c[s]&&c[s]>0){
      ans*=nck(c[t]-1,c[s]);
      ans%=mod;
      ans*=kai[c[s]];
      ans%=mod;
      c[t]-=c[s];
      c[s]=0;
    }
   // cout<<c[0]<<" "<<c[1]<<endl;
  }
  ans*=kai[c[0]];
  ans%=mod;
  cout<<ans<<endl;
}
                

Measured memory_bytes: 7152
import math
a, b, C = map(float, input().split())
C = math.radians(C)
S = 1 / 2 * math.sin(C) * a * b
L = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C))
h = b * math.sin(C)
print(S)
print(L)
print(h)


Measured memory_bytes: 5692
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*int x, a;
	scanf("%d %d", &x, &a);
	if (x < a) {
		printf("0\n");
	}
	else {
		printf("10\n");
	}*/
	int n, x;
	scanf("%d %d", &n, &x);
	int l[101];
	for (int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	int d=0;
	int count = 1;
	for (int i = 0; i < n; i++) {
		d = d + l[i];
		if (d <= x)count++;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
# -*- coding:utf-8 -*-
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
count = 0
for row in a:
    sum = c
    for v1, v2 in zip(row, b):
        sum += v1 * v2
    if sum > 0:
        count += 1
print(count)

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

if S != 10 ** 18:
    q = S // 10 ** 9 + 1
    r = 10 ** 9 * q - S
else:
    q = S // 10 ** 9
    r = 10 ** 9 * q - S

print(0, 0, q, r, 1, 10 ** 9)

Measured memory_bytes: 3060
#!/usr/bin/env python3
#ABC136 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,k = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
lst = []
for i in range(1,int(math.sqrt(s))+1):
    if s % i == 0:
        if i != s//i:
            lst.append(i)
            lst.append(s//i)
        else:
            lst.append(i)
lst.sort()
for i in lst[::-1]:
    x = [[j%i,-j%i] for j in a]
    x.sort()
    b = [j for j,k in x]
    c = [k for j,k in x]
    #+1をするリスト
    b = list(accumulate(b))
    #-1をするリスト
    c = list(accumulate(c))
    for j in range(n-1):
        if b[j] == c[-1]-c[j]:
            ans = b[j]
            break
    if ans <= k:
        print(i)
        break


Measured memory_bytes: 44892
#include <stdio.h>
#include <stdlib.h>

int main(){
  char input[7];
  int num[100];
  int i = 0;

  while(scanf("%s", input) != EOF){
    if(input[0] == '+') num[i-2] = num[i-2] + num[i-1];
    else if(input[0] == '-') num[i-2] = num[i-2] - num[i-1];
    else if(input[0] == '*') num[i-2] = num[i-2] * num[i-1];
   
    else {
      num[i] = atoi(input);
      i += 2;
    }
    i--;
  }
  
  printf("%d\n", num[0]);
 
  return 0;
}

Measured memory_bytes: 1848
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (N, X) = listOfInt()
    val L = listOfInt()
    var d = 0
    var ans = 1
   for  (n in 0 until N) {
        d += L[n]
        if (d <= X) ans++
    }
    println("${ans}")
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 37896
import numpy as np


def solve(a):
    b = np.bincount(a)
    be = b*(b-1)//2
    ans = np.sum(be)
    for i in range(n):
        print(ans-max((b[a[i]]-1),0))
    return





n = int(input())
a = [int(s) for s in input().split(" ")]
solve(a)

Measured memory_bytes: 34044
#include <iostream>
#include <stdlib.h>

#define M (1000)
typedef struct {
    int height;
    int v1, v2;
}line;

int srt(const void* p1, const void* p2) {
    // 降順にするので逆
    return ((line*)p2)->height - ((line*)p1)->height;
}

int main(void) {
  line l[M];
  int n, m, a;
  
  while(true) {
    std::cin >> n >> m >> a;
    //std::cin.ignore();
    if(a == 0) break;
    for(int i=0; i<m; i++) {
      std::cin >> l[i].height >> l[i].v1 >> l[i].v2;
      //std::cout << l[i].height << l[i].v1 << l[i].v2 << std::endl;
    }
    qsort(l, m, sizeof(line), srt);
    
    for(int i=0; i<m; i++)
      if(a == l[i].v1 || a == l[i].v2)
        a = (a == l[i].v1) ? l[i].v2 : l[i].v1;
    std::cout << a << std::endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int n; cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i){
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end(), greater<int>());
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            ans += vec[i];
        } else {
            ans -= vec[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n;
  long res;
  cin.scan(n);

  foreach (i; 1 .. n + 1) {
    if (!(i % 3 == 0 || i % 5 == 0)) {
      res += i;
    }
  }

  writeln(res);
}


Measured memory_bytes: 3184
s = gets.chop
t = gets.chop

def compare_string(a, b) 
  res = 0
  a.length.times do |i|
    if a[i] != b[i] 
      res += 1  
    end
  end
  return res
end

ans = 1005
(s.length - t.length + 1).times do |i|
  c = compare_string(t, s[i, t.length])
  if c < ans
    ans = c
  end
end

puts(ans)

Measured memory_bytes: 14236
#include <iostream>
#include <utility>
#include <stdint.h>
#include <map>
#include <queue>

using namespace std;

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

  multimap<int,int> MAP;

  for (int m=0; m<M; ++m) {
    int a, b;
    cin >> a >> b;

    MAP.emplace(a,b);
    MAP.emplace(b,a);
  }

  vector<int> X(N+1,0);

  queue<int> Q;

  auto er = MAP.equal_range(1);
  for (auto itr = er.first; itr != er.second; ++itr) {
    int room = itr->second;
    X[room] = 1;
    Q.emplace(room);
  }
  
  while (!Q.empty()) {
    int room = Q.front();
    Q.pop();

    auto er = MAP.equal_range(room);
    
    for (auto itr = er.first; itr != er.second; ++itr) {
      int next_room = itr->second;
      if (X[next_room] != 0)
	continue;
      X[next_room] = room;
      Q.emplace(next_room);
    }
  }

  bool flag = true;
  for (int ii=2; flag && ii<X.size(); ++ii) {
    if (X[ii]==0) {
      flag = false;
      break;
    }
  }

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

  for (int ii=2; ii<X.size(); ++ii) {
    cout << X[ii] << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    unordered_map<int, int> mp;
    for (int i = 0; i < N; i++) {
        int pi;
        cin >> pi;
        mp[pi] = i;
    }

    multiset<int> ms;
    ms.insert(-1);
    ms.insert(-1);
    ms.insert(N);
    ms.insert(N);
    ll ans = 0;
    for (int i = N; i >= 1; i--) {
        int a = mp[i];
        auto itr = ms.insert(a);
        int w, x, y, z;
        x = *(--itr);
        w = *(--itr);
        ++itr, ++itr;
        y = *(++itr);
        z = *(++itr);
        ans += (ll)(x - w) * (y - a) * i;
        ans += (ll)(a - x) * (z - y) * i;
    }

    cout << ans << endl;


    return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b, t;
    cin >> a >> b >> t;

    int i = 0;
    while (true){
        t = t - a;
        if (t < 0){
            break;
        }
        i += 1;
    }
    cout << i*b;

    return 0;
}


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


int main(int argc, char const *argv[])
{	


	int h1,m1,h2,m2,K;
	cin>>h1>>m1>>h2>>m2>>K;
	if(m1>m2){h2--;m2+=60;}
	
	cout<< (h2-h1)*60+(m2-m1)-K<<endl;
	return 0;
}

Measured memory_bytes: 3616
/*
      author : nishi5451
      created: 11.08.2020 21:42:10
*/

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


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

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n,x; cin >> n >> x;
    ll ans = 0;
    int a[n];
    rep(i,0,n) cin >> a[i];
    rep(i,0,n-1) {
        int sum = a[i] + a[i+1];
        if(sum <= x) continue;
        if(sum-x <= a[i+1]){
            a[i+1] -= (sum-x);
        }else {
            a[i+1] = 0;
        }
        ans += sum-x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    string s;
    cin>>s;
    int n = s.size();
    int c[n];
    int j = 0;
    for(int i = 0; i<n; i++) c[i] = 0;
    for(int i = 0; i<n; i++){
      if(s[i] == 'A'||s[i] == 'T'||s[i] == 'C'||s[i] == 'G') c[j]++;
      else j++;
    }
    int max = 0;
    for(int i = 0; i<n; i++) {
      if(c[i]>max) max=c[i];
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
fun main() {
    val builder = StringBuilder()

    val n = readInputLine().toLong()

    var nTmp = n

    var len = 0

    var currentBase = 26L
    var currentSum = 0L

    while (true) {
        len++
        currentSum += currentBase

        if (currentSum >= n) {
            break
        }

        nTmp -= currentBase

        currentBase *= 26L
    }

    val ans = CharArray(len) { 'a' }

    val str = (nTmp - 1L).toString(26).padStart(len, '0')

    for (i in str.indices) {
        ans[i] = 'a' + str[i].toString().toInt(26)
    }

    builder.appendln(ans.joinToString(""))

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 39476
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

ll mod(double a, double b){
	return a - floor(a / b) * b;
}

int main(){
	IOS;
	ll x, y;
	cin >> x >> y;
	dump(abs(x - y) <= 1 ? "Brown" : "Alice");
}

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

class Cmondai
{
    static void Main()
    {
        var nx = Console.ReadLine().Split(' ').Select(value => Int64.Parse(value)).ToArray();
        var N = nx[0];
        var x=Console.ReadLine().Split(' ').Select(value => Int64.Parse(value)).ToList();
        x.Add(nx[1]);
        x=x.OrderByDescending(value => value).ToList();
        var list = new List<long>();
        for(int i = 0; i < N; ++i) list.Add(x[i] - x[i + 1]);
        var ans = list[0];
        for (int i = 1; i < list.Count(); ++i)
        {
            var a = ans < list[i] ? list[i] : ans;
            var b = a == ans ? list[i] : ans;
            ans = GetGcd(a, b);
        }
        Console.WriteLine(ans);
    }
    static long GetGcd(long a, long b)
    {
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}

Measured memory_bytes: 28000
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int c=0;
    for(int i = 0 ; i<s.size() ; i++)
    {
        if( islower(s[i]))
        {
        }
        else
        {
            c++;
        }
    }
    int i=0;
    for(int x=2; x<s.size()-1 ; x++)
    {
        if (c==2&&s[i]=='A'&&s[x]=='C')
        {
            cout<<"AC";return 0;
        }
    }
    cout<<"WA";
    return 0;
}


Measured memory_bytes: 256
alice = 0
bob = 0
n = int(input())
a = list(map(int,input().split()))
sorted_a = sorted(a, reverse=True) 

for i in range(n):
	if i % 2 == 0:
		alice += sorted_a[0]
	else:
		bob += sorted_a[0]
	sorted_a.pop(0)

print(alice - bob)

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

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

int main() {
  ll a, b;
  cin >> a >> b;

  ll ans = -1;
  for (ll i = 1; i <= 10000; ++i) {
    ll ta = i * 0.08;
    ll tb = i * 0.1;

    if (a == ta && b == tb) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;


int main(){
    int n,q;cin>>n>>q;
    string s;cin>>s;
    vin l(q),r(q);
    rep(i,q)cin>>l[i]>>r[i];
    vin count(n+1);
    count[0]=0;
    int sum=0;
    rep2(i,1,n+1){
        if(s[i-1]=='A'&&s[i]=='C')sum++;
        count[i]=sum;
    }
    rep(i,q){
        if(l[i]==1)cout<<count[r[i]-1]<<endl;
        else if(s[l[i]-2]=='A'&&s[l[i]-1]=='C')cout<<count[r[i]-1]-count[l[i]-2]-1<<endl;
        else cout<<count[r[i]-1]-count[l[i]-2]<<endl;
    }
}

Measured memory_bytes: 2176
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0, s = 0;
  scanf("%lld", &n);
  ll a[n], b[n], as[2 * n], bs[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) scanf("%lld", &b[i]);
  for(i = 0; i < n; ++i) as[i] = a[i] ^ a[(i + 1) % n], bs[i] = b[i] ^ b[(i + 1) % n];
  for(i = 0; i < n; ++i) as[i + n] = as[i];
  ll t[n];
  t[0] = -1;
  for(i = 1; i < n; i++) {
    if(i - 1 && bs[i - 1] == bs[t[i - 1]]) t[i] = t[i - 1] + 1;
    else t[i] = 0;
  }
  for(i = 0; i < 2 * n; ++i) {
    if(i - s == n) {
      printf("%lld %lld\n", s, a[s] ^ b[0]);
      s = i - t[n - 1] - 1;
    }
    while(i - s && bs[i - s] != as[i]) s = i - t[i - s];
    if(!(i - s) && bs[i - s] != as[i]) s = i + 1;
  }
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi A(N);
    rep(i,N) cin>>A.at(i);
    vector<pii> p;
    rep(i,N) {
        p.pb(make_pair(A.at(i),i+1));
    }
    sort(all(p));
    for(auto c : p) {
        cout<<c.se<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 2164
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i


coin500 = [*0..a]
coin100 = [*0..b]
coin50 = [*0..c]

puts coin500.product(coin100,coin50).collect{|arr| arr[0]*500 + arr[1]*100 + arr[2]*50}.select{|num| num == x}.size


Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 305;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmax(T &x, T y) {
    if (x < y) x = y;
}

char s[N];
int n, K;
int dp[N][N][N];

void init() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    read(K);
}

void solve() {
    for (int i = 1; i <= n; ++i) {
        for (int k = 0; k <= K; ++k) {
            dp[i][i][k] = 1;
        }
    }
    for (int i = 1; i < n; ++i) {
        for (int l = 1, r; (r = l + i) <= n; ++l) {
            for (int k = 0; k <= K; ++k) {
                cmax(dp[l][r][k], dp[l + 1][r][k]);
                cmax(dp[l][r][k], dp[l][r - 1][k]);
                if (s[l] == s[r]) {
                    cmax(dp[l][r][k], dp[l + 1][r - 1][k] + 2);
                } else if (k > 0) {
                    cmax(dp[l][r][k], dp[l + 1][r - 1][k - 1] + 2);
                }
            }
        }
    }
    int ans = 0;
    for (int k = 0; k <= K; ++k) {
        cmax(ans, dp[1][n][k]);
    }
    printf("%d", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 110464
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll num[1000005];
ll n,m,b,c;
ll ans=0,now=0;
vector<pair<ll,ll> > v;
bool cmp(pair<ll,ll> x,pair<ll,ll> y) {
	if (x.second!=y.second) return x.second>y.second;
	else return x.first>y.first;
}
signed main() {
	cin>>n>>m;
    for(ll i=1;i<=n;i++) {cin>>num[i];}
    sort(num+1,num+n+1);
    for(ll i=1;i<=m;i++) {
        cin>>b>>c;
        v.push_back(make_pair(b,c));
    }
    sort(v.begin(),v.end(),cmp);
    now=1;
    for(ll i=0;i<v.size();++i) {
        for(ll j=1;j<=v[i].first&&v[i].second>num[now]&&now<=n;++j) {
    		num[now++]=v[i].second;
        }
    }
    for(ll i=1;i<=n;i++) ans+=num[i];
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3188
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) (v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        int  a, b; cin >> a >> b;
        int ans = a+b;
        if(ans>=24)ans = abs(ans-24);
        cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 384
import sys
import collections
input = sys.stdin.readline

def main():
    N, T = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    maxlist = [0] * N
    ma = 0
    for i in range(N - 1, -1, -1):
        ma = max(ma, A[i])
        maxlist[i] = ma

    c = collections.Counter()

    for i in range(N - 1):
        c[maxlist[i + 1] - A[i]] += 1

    m = sorted(c.keys(), reverse=True)


    print(c[m[0]])



    
    
    

if __name__ == '__main__':
    main()




Measured memory_bytes: 21784
N = int(input())
A, B = [0]*N, [0]*N
for i in range(N):
  A[i], B[i] = map(int, input().split())

ans = 0
for i in range(N-1, -1, -1):
  ans += (B[i] - ((A[i] + ans) % B[i])) % B[i]

print(ans)

Measured memory_bytes: 10868
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

cnt = 0
for i in range(N):
    if i > 0:
        if A[i - 1] == 1 and A[i] > 0:
            A[i] -= 1
            cnt += 1
            A[i - 1] -= 1
    cnt += A[i] // 2
    A[i] %= 2

print(cnt)


Measured memory_bytes: 50136
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
 
using namespace std;
 
int main(int argc, char* argv[])
{
 
	int a,b,c;
 
	cin >> a >> b >> c;
 
	cout << min(a+b,min(b+c,a+c)) << endl;
 
 
	return 0;
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.valueOf(sc.nextLine());
        int a = Integer.valueOf(sc.nextLine());
        int b = Integer.valueOf(sc.nextLine());
        int result = (x - a) % b;
        System.out.println(result);   
        sc.close();
    }
}

Measured memory_bytes: 21844
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int  ,long long int> P;

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

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

int main(void)
{
	while(1){
		int n, m;

		cin >> n >> m;
		if(n==0&&m==0){
			break;
		}
		int t, s, d;
		vector<pair<int, pair<int,int> > > pa(m);
		vector<int> com(n + 1,0);
		int count = 0;
		com[1] = 1;
		FOR(i, 0, m - 1)
		{
			cin >> t >> s >> d;
			pa[i].first = t;
			pa[i].second.first=s;
			pa[i].second.second = d;
		}
		sort(pa.begin(), pa.end());
		FOR(i,0,m-1){
			if(com[pa[i].second.first]==1){
				com[pa[i].second.second] = 1;
			}
		}

		FOR(i,1,n){
			if(com[i]==1){
				count++;
			}
		}

		cout << count << endl;
	}
}



Measured memory_bytes: 3400