akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N,M=MI()
LR=LLI(M)

maxL=0
minR=11111111111111111

for lr in LR:
    maxL=max(maxL, lr[0])
    minR=min(minR, lr[1])    
            
print(max(minR-maxL+1, 0))

Measured memory_bytes: 29576
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;

signed main(){
	double x;
	cin>>x;
	double now=100;
	double t=1.0;
	
	if(now>=x){
			cout<<0<<endl;
			return 0;
		}
	rep(i,INF){
		now*=1.01;
		int now2=(int)now;
		now=(double)now2;
		if(now>=x){
			cout<<i+1<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define pb push_back
#define int long long
//#define M 998244353
#define M 1000000007
using namespace std;
const int inf=4e18;
const int MX=100;
const int MN=-100;
const double pi=3.14159265358979;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,i;cin>>n;
	string s[n+1];
	map<string,int> mp;
	for(i=1;i<=n;i++)
	{
		int t;cin>>s[i]>>t;;
		mp[s[i]]=mp[s[i-1]]+t;
	}
	string s1;cin>>s1;
	cout<<mp[s[n]]-mp[s1]<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n, r;
	cin >> n >> r;

	println((n >= 10 ? r : r + (10 - n) * 100));
}

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

#define EPS 1.0e-12
using namespace std;

struct CPoint{
	CPoint():x(-1),y(-1){}
	CPoint(double x, double y):x(x),y(y){}
	double x,y;
};
struct CSeal{
	CSeal():r(0){}
	CSeal(double x, double y):p(x,y),r(1.0){}
	CPoint p;
	double r;
};
inline double Distance(const CPoint &a, const CPoint &b){
	return sqrt( pow(b.x - a.x, 2.0) + pow(b.y - a.y, 2.0) ); 
}
inline double Distance(const CSeal &a, const CSeal &b){
	return Distance( a.p, b.p );
}
pair<CPoint,CPoint> CrossPoints(const CSeal &a, const CSeal &b)
{
	pair<CPoint, CPoint> ans;
	
	if( Distance(a,b) > 2 ){
		ans.first.x = -1;
		ans.first.y = -1;
		ans.second.x = -1;
		ans.second.y = -1;
		return ans;
	}

	if( a.p.x == b.p.x )
	{
		double D = Distance(a, b);
		double off = sqrt(1-pow((D/2),2));
		ans.first.x = a.p.x - off;
		ans.second.x = a.p.x + off;
		if( a.p.y >= b.p.y )
			ans.first.y = a.p.y - D/2;
		else
			ans.first.y = b.p.y - D/2;
		ans.second.y = ans.first.y;
	}
	else
	{
		double xa = a.p.x;
		double xb = b.p.x;
		double ya = a.p.y;
		double yb = b.p.y;
		double A = (xa+xb)/2 - ( (pow(yb,2)-pow(ya,2)) / (2*(xa-xb)) );
		double m = (yb-ya)/(xa-xb);

		double aVal = 1 + pow(m,2);
		double bVal = m*(A-xb)-yb;
		double cVal = pow(A,2)+pow(xb,2)+pow(yb,2)-2*xb*A-1;

		//cout << "b=" << bVal << "\ta=" << aVal << "\tc=" << cVal << "\tD=" << pow(bVal,2) - aVal * cVal << endl;

		ans.first.y = (-bVal + sqrt( pow(bVal,2) - aVal * cVal )) / aVal;
		ans.second.y = (-bVal - sqrt( pow(bVal,2) - aVal * cVal )) / aVal;
		ans.first.x = A + m*ans.first.y;
		ans.second.x = A + m*ans.second.y;
	}

	if( Distance(a,b) == 2 ){
		ans.second.x = -1;
		ans.second.y = -1;
	}
	return ans;
}
inline bool inPaper( const CPoint &p ){
	return p.x >= 0 && p.y >= 0 && p.x <= 10 && p.y <= 10;
}
int main(void){
	/*CSeal sa(0,0),sb(0,2);
	pair<CPoint,CPoint> tmp = CrossPoints(sa,sb);
	cout << tmp.first.x << " " << tmp.first.y << "," << tmp.second.x << " " << tmp.second.y << endl;*/
	
	while( true ){
		int n;
		unsigned int maxOverlapped = 1;
		vector<CSeal> vSeals;
		vector<CPoint> vCrossPoints;

		cin >> n;
		if( n == 0 ) break;

		for(int i = 0; i < n; ++i){
			double x, y;

			cin >> x;
			cin.ignore(1);
			cin >> y;
			CSeal tmp(x, y);
			vSeals.push_back(tmp);
		}

		for(unsigned int i = 0; i < vSeals.size(); ++i){
			for(unsigned int j = i; j < vSeals.size(); ++j){
				if( i != j ){
					pair<CPoint, CPoint> cp;
					cp = CrossPoints( vSeals[i], vSeals[j] );
					if( inPaper( cp.first ) ){
						vCrossPoints.push_back( cp.first );
					}
					if( inPaper( cp.second ) ){
						vCrossPoints.push_back( cp.second );
					}
				}
			}
		}

		for(unsigned int i = 0; i < vCrossPoints.size(); ++i){
			unsigned int overlapped = 0;
			for(unsigned int j = 0; j < vSeals.size(); ++j){
				if( Distance( vCrossPoints[i], vSeals[j].p ) <= 1 + EPS ){
					++overlapped;
				}
			}
			maxOverlapped = max( maxOverlapped, overlapped );
		}

		cout << maxOverlapped << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll K, T;
  cin >> K >> T;
  vll a(T);
  priority_queue<ll> que;
  for(int i = 0; i < T; i++){
    cin >> a.at(i);
    que.push(a.at(i));
  }
  while(que.size() >= 2){
    ll f = que.top(); que.pop();
    ll s = que.top(); que.pop();
    f--; s--;
    if(f != 0) que.push(f);
    if(s != 0) que.push(s);
  }
  if(que.size() == 0) cout << 0 << endl;
  else cout << que.top() - 1 << endl;
}

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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int x, y;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			x = i;
			break;
		}
	}
	for (int i = s.length() - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			y = i;
			break;
		}
	}
	cout << y - x + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
import bisect
import time

start = time.time()

D = int(input())
c = [0] + list(map(int, input().split()))
s = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]
sch, held = [0], [[0] for _ in range(27)]

for d in range(1, D+1):
    SLvar = [s[d][i] + c[i] * (d - held[i][-1]) for i in range(1, 27)]
    t = SLvar.index(max(SLvar)) + 1
    sch.append(t)
    held[t].append(d)

for i in range(1, 27):
    held[i].append(D+1)

s_sort = [0] + [[0] + sorted([[s[d][i], i] for i in range(1, 27)], key=lambda x: x[0], reverse=True) for d in range(1, D+1)]

i, j = 1, 1
while time.time() - start < 1.8 and i <= D and j < 27:
    d, q = i, s_sort[i][j][1]

    if sch[d] != q:
        SLvar = s[d][q] - s[d][sch[d]]

        ind_p = bisect.bisect_left(held[sch[d]], d)
        k = d - held[sch[d]][ind_p-1]
        l = held[sch[d]][ind_p+1] - d
        SLvar -= c[sch[d]] * k * l

        ind_n = bisect.bisect_left(held[q], d)
        k = d - held[q][ind_n-1]
        l = held[q][ind_n] - d
        SLvar += c[q] * k * l

        if SLvar > 0:
            del held[sch[d]][ind_p]
            held[q].insert(ind_n, d)
            sch[d] = q

    i += 1
    if i > D:
        i = 1
        j += 1

for i in range(1, D+1):
    print(sch[i])


Measured memory_bytes: 10296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    string s;
    cin >> s;
    int count = 0;
    int j = 0, k = s.size() - 1;
    while (j <= k)
    {
        if (s[k] != s[j])
            count++;
        j++;
        k--;
    }
    cout << count << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int n,m;
	cin >> n>>m;
	if(n+m>0||n==0){
		cout << "1" <<endl;
	}else if(n+m == 0){
		cout << "0" <<endl;
	}else{
		cout << "-1" <<endl;
	}
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int X, Y; cin >> X >> Y;
    int ans = 0;
	if(X == 1 and Y == 1) {
        cout << 300000 + 300000 + 400000 << endl;
    }
    else {
        if(X == 1) ans += 300000;
        if(X == 2) ans += 200000;
        if(X == 3) ans += 100000;
        if(Y == 1) ans += 300000;
        if(Y == 2) ans += 200000;
        if(Y == 3) ans += 100000;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#include<cstring>
#define ll long long
#define sci(a) scanf("%d",&a)
#define scl(a) scanf("%I64d",&a)
#define scs(a) scanf("%s",a)
#define pri(a) printf("%d",a)
#define prl(a) printf("%I64d",a)
#define prc(a) printf("%c",a)
const int N=1e5+5;
const int M=1e5+5;
const ll INF=1e15+7;
const double PI=acos(-1);
using namespace std;
ll n,a[10];
int main(){
	scanf("%lld",&n);
	for(int i=0;i<5;++i) scanf("%lld",&a[i]);
	ll small=INF;
	for(int i=0;i<5;++i) if(small>a[i]) small=a[i];
	ll ans=4;
	ans+=n/small;
	if(n%small!=0) ans++;
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
	int n, k, l;
	double ans, temp;
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		l = ceil(log2((k + i - 1) / i));
		temp = 1.0 / (double) n;
		while (l--)
			temp *= 0.5;
		ans += temp;
	}
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

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

int main() {
	vector<double> ans;
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		VI s(n);
		rep(i, n)cin >> s[i];
		double avg = (double)accumulate(ALL(s), 0) / n;
		vector<double> s2(n);
		rep(i, n) {
			s2[i] = abs(avg - (double)s[i]);
			s2[i] *= s2[i];
		}
		ans.PB(sqrt(accumulate(ALL(s2), 0.0) / n));
	}
	for (auto a : ans) {
		printf("%.12f\n", a);
	}
}


Measured memory_bytes: 3268
import collections

N = int(input())
A = list(map(int, input().split(' ')))

A_counter= collections.Counter(A)

_sum = 0
for count in A_counter:
    _sum += (A_counter[count]* (A_counter[count]-1)) // 2

for k in range(N):
    l = (A_counter[A[k]]) *  (A_counter[A[k]]-1)//2
    m = (A_counter[A[k]]-1) *  (A_counter[A[k]]-2)//2
    # print(_sum)
    # print(c_a)
    print(_sum -l + m)

Measured memory_bytes: 26780
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);

int main()
{
    SPEED;

    string s,t;
    cin>>s>>t;

    int n=s.size() , m=t.size();

    int mn=INT_MAX;

    for(int i=0;i<=n-m;i++)
    {
        int k=i,c=0;
        for(int j=0;j<m;j++)
        {
            if(s[k]!=t[j]) c++;

            k++;
        }
        //cout<<c<<"\n";

        mn=min(mn,c);
    }

    cout<<mn<<"\n";
}

Measured memory_bytes: 3588
#include <stdio.h>
int main()
{
	int A,B,c,d;
	scanf("%d %d",&A,&B);
	int i=10;
	d=i*0.1;
	while(d<=B)
	{
		c=i*0.08;
		d=i*0.10;
		if(c==A&&d==B) break;
		i++;
	}
	if(d>B) printf("-1");
	else printf("%d",i);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>

#define ll long long
using namespace std;


int main(int argc, char* argv[]){
	int n;
	scanf("%d",&n);
	ll A[n];
	for(int i=0;i<n;i++){
		scanf("%lld",&A[i]);
	}
	int sagaku[n];
	sagaku[0] = 0;
	for(int i=1; i<n;i++){
		sagaku[i] = A[i]-A[i-1];
//		printf("%d\n",sagaku[i]);
	}
	int baibai[n];
	int state;

	if(sagaku[1]>sagaku[0]){
		baibai[0]=1;//買い
		state = 1;
	}else if(sagaku[1]==sagaku[0]){
		baibai[0]=0;
		state = -1;
	}else if(sagaku[1]<sagaku[0]){
		baibai[0]=0;
		state = -1;
	}
	for(int i=1; i<n-1; i++){
		if(state==1 && sagaku[i+1]>0){
			baibai[i] = 0;
		}else if(state==1 && sagaku[i+1]<0){
			baibai[i] = -1;//売り
			state = -1;
		}else if(state==-1 && sagaku[i+1]>0){
			baibai[i] = 1;//買い
			state = 1;
		}else if(state==-1 && sagaku[i+1]<0){
			baibai[i] = 0;
		}else{
			baibai[i] = 0;
		}
//		printf("b %d\n",baibai[i]);
	}
	if(state==1){
		baibai[n-1] = -1;
	}else if(state==1){
		baibai[n-1] = 0;
	}
	ll money = 1000;
	ll kabu = 0;
	for(int i=0; i<n; i++){
		if(baibai[i]==1){
			ll kabu_to_buy = money/A[i];
			kabu += kabu_to_buy;
			money -= A[i]*kabu_to_buy;
//			printf("%d %lld %d\n", baibai[i], money, kabu);
		}else if(baibai[i]==-1){
			ll kabu_to_sell = kabu;
			money += A[i]*kabu_to_sell;
			kabu = 0;
//			printf("%d %lld %d\n", baibai[i], money, kabu);
		}
	}
	printf("%lld\n",money);

}


Measured memory_bytes: 3832
def comb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n-r)
import math

MOD = 10 ** 9 + 7
N, K = map(int, input().split())
ans = 0
for j in range(K):
    if N-K - j < 0:
        print(0)
        continue
    tmp = (comb(N-K+1, j+1)) % MOD
    print(int((comb(K-1, j) * tmp) % MOD))


Measured memory_bytes: 3316
/*

try computing how many sequences have a specific median?

try bsearch?
select x
everything >=x becomes 1
everything <x becomes -1

then do a div-conquer to count how many substrings have 1 as the median

*/

#include <stdio.h>

int n;
int a[100005];

int b[100005];

const int MID=100000;
int l[200005];
int r[200005];

long long divconquer(int lo,int hi)
{
    if (lo>hi) return 0;
    if (lo==hi) {
        if (b[lo]==1) return 1;
        return 0;
    }
    int mid=(lo+hi)/2;
    long long ans=divconquer(lo,mid)+divconquer(mid+1,hi);
    // want substring to sum to >=0
    // do the left side
    int sz=hi-mid+1;
    for (int i=-sz; i<=sz; i++) l[i+MID]=0;
    int t=0;
    for (int i=mid; i>=lo; i--) {
        t-=b[i];
        l[t+MID]++;
    }
    // prefix sum
    for (int i=-sz; i<sz; i++) l[i+MID+1]+=l[i+MID];
    // do the right side
    t=0;
    for (int i=mid+1; i<=hi; i++) {
        t+=b[i];
        ans+=l[t+MID];
    }
    return ans;
}

bool good(int x)
{
    for (int i=0; i<n; i++) {
        if (a[i]>=x) b[i]=1;
        else b[i]=-1;
    }
    long long s=((n+1)*(long long)n)/2;
    long long t=divconquer(0,n-1);
    //printf("%d %lld %lld\n",x,t,s);
    return t*2>=s;
}

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&n);
    for (int i=0; i<n; i++) scanf("%d",a+i);
    int lo=0,hi=1000000000;
    while (lo<hi) {
        int mid=(lo+hi+1)/2;
        if (good(mid)) {
            lo=mid;
        }
        else {
            hi=mid-1;
        }
    }
    printf("%d\n",lo);
}


Measured memory_bytes: 1280
n, l = [int(x) for x in input().split()]
res = 0
if l > 0:
  res = (n - 1) * (2 * l + n) // 2
elif l + n - 1 < 0:
  res = (n - 1) * (l + l + n - 2) // 2
else:
  res = n * (l + l + n - 1) // 2
print(res)
  

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<int,int> ma;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		ma[a]++;
		if(ma[a]>=2)
		{
			cout<<"NO"<<"\n";
			return 0;
		}
	}
	cout<<"YES"<<"\n";
	return 0;
}

Measured memory_bytes: 12804
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define ll long long
#define MOD 1000000007
ll int Fact(ll int);

int main(void){
ll int N,M;
scanf("%lld%lld",&N,&M);
if(abs(M-N)>=2) printf("0\n");
else if(abs(M-N)==1){
 printf("%lld\n",(Fact(M)*Fact(N))%MOD);
}else{
 printf("%lld\n",(Fact(M)*Fact(N)*2)%MOD);
}
return 0;
}

ll int Fact(ll int n){
 if(n==0) return 1;
 else{
  return n*Fact(n-1)%MOD;
 }
}

Measured memory_bytes: 1664
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int32_t main()
{
	map<string,int> m;
	m["SUN"] = 7;
	m["MON"] = 6;
	m["TUE"] = 5;
	m["WED"] = 4;
	m["THU"] = 3;
	m["FRI"] = 2;
	m["SAT"] = 1;
	string s;
	cin >> s;
	cout << m[s] << endl;
}
	

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

typedef long long ll;

const ll MAX = 1000000000;

int main()
{
	int n, k;
	ll a;
	scanf("%d%d", &n, &k);
	mcf_graph<int, ll> graph(n*2+2);
	int s = n*2, t = n*2+1;
	for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
		scanf("%lld", &a);
		graph.add_edge(i, n+j, 1, MAX-a);
	}
	graph.add_edge(s, t, n*k, MAX);
	for (int i = 0; i < n; ++i) {
		graph.add_edge(s, i, k, 0);
		graph.add_edge(n+i, t, k, 0);
	}
	auto ans = graph.flow(s, t, n*k);
	printf("%lld\n", MAX*n*k-ans.second);
	char grid[n][n+5];
	memset(grid, '.', sizeof grid);
	auto edges = graph.edges();
	for (auto e : edges) {
		if (e.from != s && e.to != t && e.flow) {
			grid[e.from][e.to-n] = 'X';
		}
	}
	for (int i = 0; i < n; ++i) {
		grid[i][n] = '\0';
		printf("%s\n", grid[i]);
	}
}

Measured memory_bytes: 4056
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int i;
	int sum_a;
	int sum_b;
	
	sum_a = 0;
	sum_b = 0;
	for (i = 0; i < 4; i++){
		scanf("%d", &a[i]);
	}
	for (i = 0; i < 4; i++){
		scanf("%d",& b[i]);
	}
	
	for (i = 0; i < 4; i++){
		sum_a += a[i];
		sum_b += b[i];
	}
	
	if (sum_a == sum_b){
		printf("%d\n", sum_a);
	}
	else if (sum_a > sum_b){
		printf("%d\n", sum_a);
	}
	else {
		printf("%d\n", sum_b);
	}
	
	return (0);
}

Measured memory_bytes: 1756
n = int(input())
a = list(map(int,input().split()))

ad = {}
for i in range(n) :
    if a[i] in ad :
        ad[a[i]] += 1
    else :
        ad[a[i]] = 1

ans = 0
for v in ad.values():
    ans += v*(v-1)//2

for i in range(n):
    v = ad[a[i]]
    print(ans-v*(v-1)//2+(v-1)*(v-2)//2)

Measured memory_bytes: 24748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArr = br.readLine().split(" ");
        int a,b,c;
    	int count = 0;

    	a = Integer.parseInt(strArr[0]);
    	b = Integer.parseInt(strArr[1]);
    	c = Integer.parseInt(strArr[2]);

		for(int i = a; i <= b; i++){
			if(c % i == 0){
				count++;
			}
		}

		System.out.println(count);

    }
}

Measured memory_bytes: 24456
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,cou;
    char S[100000];
    scanf("%d %d",&A,&B);
    if((A+B>=A-B)&&(A+B>=A*B)){
        printf("%d",A+B);
    }else if((A-B>=A+B)&&(A-B>=A*B)){
        printf("%d",A-B);
    }else if((A*B>=A-B)&&(A*B>=A+B)){
        printf("%d",A*B);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

struct P
{
	vector<int> mem[3];
	ll point;
};
int n, m;
int vis[15000000] = {-1};
queue<P> que; 

ll cal_point(P p){
	ll point = 0; 
	rep(i,3){
		rep(j,p.mem[i].size()){
			point += i * pow(3,p.mem[i][j]-1);
		}
	}
	return point;
}

void INIT(){
	memset(vis,-1,sizeof(vis));
	while(!que.empty()){
		que.pop();
	}
}

P Change(P p, int num1, int num2){
	int l = p.mem[num1].size()-1;
	int tmp = p.mem[num1][l];
	p.mem[num1].pop_back();
	p.mem[num2].push_back(tmp);
	return p;
}

void PRINT(P p){
	char alp = 'A';
	cout << "###########" << endl;
	rep(i,3){
		cout << char(alp+i) << ":";
		rep(j,p.mem[i].size()){
			cout << p.mem[i][j] << " ";
		}
		cout << endl;
	}
	cout << "###########" << endl;
}

int BFS(){
	int step = 0;
	while(!que.empty()){
		P p = que.front(); que.pop();

		if(vis[p.point]>m){
			step = -1;
			break;
		}
		//cout << "point is " << p.point << "; step is " << vis[p.point] << endl;//
		//PRINT(p);

		if(p.mem[1].size()==0 && 
			(p.mem[0].size()==0 || p.mem[2].size()==0)){
			step = vis[p.point];
			break;
		}

		int L[3]; 
		rep(i,3) L[i] = p.mem[i].size()-1;

		rep(i,3) rep(j,3){ // from L[i] to L[j]
			if(abs(i-j)!=1) continue;
			if(L[i]>=0){ // from 
				int ok = 0;
				if(L[j]>=0){ // to
					if(p.mem[i][L[i]] >= p.mem[j][L[j]]) ok = 1;
				}
				else if(p.mem[j].size() == 0) ok = 1;

				if(ok){
					P np = Change(p,i,j); //更新後の状態
					np.point = cal_point(np);
					if(vis[np.point]==-1){
						vis[np.point] = vis[p.point]+1;
						que.push(np);
					} 
				}
			}
		}
	}
	//cout << "!!"  << endl;
	return step;
}

int main(){
	while(1){
		INIT();
		cin >> n >> m;
		if(!n&&!m) break;

		P tmp;
		rep(i,3){
			int num, inp;
			cin >> num; //the number of dish
			rep(j,num){
				cin >> inp;
				tmp.mem[i].pb(inp);
			}
			tmp.point = cal_point(tmp);
		}

		//cout << tmp.point << endl;
		vis[tmp.point] = 0;
		que.push(tmp);

		int ans = BFS();

		cout << ans << endl; 
	}

}


Measured memory_bytes: 61880
#include "bits/stdc++.h"
using namespace std;
#define INF 1e18
typedef long long ll;
ll cost = 1e18; 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n,m,x ; cin>>n>>m>>x;
	vector<vector<int>> book(n,vector<int>(m+1));
	for(int i =0;i<n;i++)
	{
		for(int j=0;j<m+1;j++)
		{
			cin>>book[i][j];
		}
	}

	//iterate over 2^n possibility of books.
	//for each chosen combination of books: check how much knowledge is gained. also check cost.
	//consider min cost.
	for(int i=1;i< (1<<n) ; i++)
	{
		vector<ll> knowledgeGained(m);
		ll combination_cost=0;
		//i is chosen combination. lets say 10011
		//now go through each book and find bit set.
		for(int j =0;j<n;j++)
		{
			if(i&(1<<j)) // if jth bit is set ==> buy jth book.
			{
				combination_cost+=book[j][0];
              	// each book adds knowledge 
				for(int k=0;k<m;k++)
				{
					knowledgeGained[k] += book[j][k+1];
				}
			}
		}
		bool ok = 1;
		for(ll i: knowledgeGained)
		{
			if(i<x){
				ok=0; break;
			}
		}
		if(ok){
			cost = min(cost,combination_cost);
		}

	}

	if(cost==1e18) return cout<<-1<<"\n" ,0;
	else return cout<<cost<<"\n" ,0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll n;
    cin >> n;
    vector<ll> as(n+2, 0);
    for (auto &&i: boost::irange(1LL, n+1)){
        cin >> as.at(i);
    }
    vector<ll> ds(n, 0);
    for (auto &&i: boost::irange(0LL, n)){
        ll a1{as.at(i)}, a2{as.at(i+1)}, a3{as.at(i+2)};
        ll d;
        if ((a1 <= a2 && a2 <= a3) || (a3 <= a2 && a2 <= a1))d=0;
        else if ((a1 <= a3 && a3 <= a2) || (a2 <= a3 && a3 <= a1)) d = abs(a3-a2) * 2;
        else d = abs(a1-a2)*2;
        ds.at(i) = d;
    }
    ll s{0};
    for (auto &&i: boost::irange(0LL, n+1)){
        s += abs(as.at(i)-as.at(i+1));
    }
    for (auto &&i: boost::irange(0LL, n)){
        cout << s-ds.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 2816
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;

int main(){
  long long sum = 0;
  int n,a,b;
  cin >> n >> a >> b;
  
  cout << (a*n > b ? b : a*n) << endl;
  return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mx = 1e5+10;
int dp[mx];
int main()
{
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    dp[2]=abs(arr[2]-arr[0]);
    for(int i=3; i<=n; i++)
    {
        dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
n = int(input())
b = list(map(int,input().split()))
ret = 0
from itertools import combinations
for x,y,z in list(combinations(range(n),3)):
    x,y,z=b[x],b[y],b[z]
    if x == y or x == z or y == z:
        continue
    else:
        if x+y>z and y+z>x and z+x>y:
            ret += 1

print(ret)

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

ll arr[2][100010];
int main(void){
	int n;
	cin >> n;
	FOR(i,n){
		cin >> arr[0][i] >> arr[1][i];
	}

	ll tot = 0;

	for(int i = n-1;i>=0;i--){
		ll cur = tot + arr[0][i];
		ll need = cur % arr[1][i];
		if(need == 0)continue;
		tot += arr[1][i] - need;
	}
	cout << tot;
    return 0;
}




Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;

#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i , n) for(int i =0 ; i < n ;i++)
#define REPN(i , n) for(int i = 1; i <= n ; i++)
#define cot(x) cerr << #x << " " << x << " ";
#define cotd(x) cerr << #x << " " << x << endl;
#define her 	cerr << " here \n"; 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())

template<typename T > void check(T & a, const T & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }
LL mulmod(LL a, LL b, const LL & m) { LL q = (LL)(((LD)a*(LD)b) / (LD)m); LL r = a*b - q*m; if (r>m)r %= m; if (r<0)r += m; return r; }
template <typename T, typename S>T expo(T e, S n) { T x = 1, p = e; while (n) { if (n & 1)x = x*p; p = p*p; n >>= 1; }return x; }
template <typename T>T powerL(T e, T n, const T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mulmod(x, p, m); p = mulmod(p, p, m); n >>= 1; }return x; }

int main(){
	SYNC; 
	int n; 
	cin >> n; 
		n *= 3; 

	vi v(n), vis(n); 
	REP(i, n) cin >> v[i]; 
	sort(ALL(v)); 

	LL ans = 0; int j = 0; 
	for(int i = n - 2; i >= 0; i -= 2){
		if(vis[i]) continue;
		//cerr << v[i] << endl; 
		ans += v[i]; 
		vis[i] = vis[i + 1] = vis[j++] = 1; 
	}
	cout << ans << endl; 
	return 0; 
}

Measured memory_bytes: 2560
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        int max=-500;
        if(max<a+b) max=a+b;
        if(max<a-b) max=a-b;
        if(max<a*b) max=a*b;
		
		//出力
		Console.WriteLine(max);
	}
}

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


int main(){

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(1000000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A):
    A.sort(reverse=True)
    T = sum(A)
    t = T / (4*M)
    for i in range(M):
        a = A[i]
        if a < t:
            return 'No'
    return 'Yes'


def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6348
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

dp = [0]*(K+1)  # dp[i] := gcdの結果がiになるのが何通りあるか
ans = 0
for i in range(K, 0, -1):
	n = K//i
	dp[i] = pow(n, N, mod)
	for j in range(2, n+1):
		dp[i] -= dp[j*i]
		dp[i] %= mod
	ans += dp[i]*i
	ans %= mod
print(ans)


Measured memory_bytes: 75940
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	ll x[1001][3];
	ll absx[8][1001];
	ll ans=0;
	scan(N);scan(M);
	rep(i,N){
		rep(j,3){
			scan(x[i][j]);
		}
	}
	rep(bit,8){
		int sign[3];
		rep(k,3){
			if(bit&(1<<k)) sign[k]=1;
			else sign[k]=-1;
		}
		rep(i,N){
			ll sum=0;
			rep(k,3){
				sum+=sign[k]*x[i][k];
			}
			absx[bit][i]=sum;
		}
	}
	rep(bit,8){
		sort(absx[bit],absx[bit]+N);
		ll sum=0;
		for(int i=N-1;i>=N-M;i--){
			sum+=absx[bit][i];
		}
		ans=max(ans,sum);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(Math.min(A * N, B));
		sc.close();
	}

}

Measured memory_bytes: 23764
grade = ""
while true
m, f, r = gets.split.map(&:to_i)
if m == -1 && f == -1 && r == -1
break 
end

if m == -1 || f == -1
 grade = "F"
elsif m + f >= 80
 grade = "A"
elsif m + f >= 65
 grade = "B"
elsif m + f >= 50
 grade = "C"
elsif m + f >= 30 && r >= 50
 grade = "C"
elsif m + f >= 30 && r < 50
 grade = "D"
else 
 grade = "F"
end

puts grade
end




Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests, vector<int>&last, vector<int>&satis, int beg) {
  //vector<int> contests(d);
  //vector<int> last(26, 0);
  for (int i = 0; i < 26; i++) last[i] = 0;
  int sat = (beg == 0) ? 0 : satis[beg-1];
  //int sat = 0;
  //makecontest(s, c, last, contests);

  for (int i = 0; i < d; i++) {
    //cout << d << " " << i << endl;
    last[contests[i]-1] = i+1;
    if (i < beg) continue;
    sat += s[i][contests[i]-1];
    for (int j = 0; j < 26; j++) {
      sat -= c[j] * (i+1 - last[j]);
    }
    //cout << sat << endl;
    satis[i] = sat;
  }
  return sat;
}

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

  int d;
  cin >> d;
  vector<int> c(26);
  for (int i = 0; i < 26; i++) cin >> c[i];
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<int> contests(d);
  //for (int i = 0; i < d; i++) cin >> contests[i];
  for (int i = 0; i < d; i++) {
    int mx = 0, ct;
    for (int j = 0; j < 26; j++) {
      mx = max(mx, s[i][j]);
      if (mx == s[i][j]) ct = j+1;
    }
    contests[i] = ct;
  }
  
  vector<int> last(26, 0);
  vector<int> satis(d, 0), rec(d);
  int sc = score(d, s, c, contests, last, satis, 0);
  for (int i = 0; i < d; i++) rec[i] = satis[i];
  //cout << sc << endl;
  for (int p = 0; p < 450000; p++) {
    srand(p);
    int day = rand() % d;
    int q = rand() % 26;
    //cout << day << " " << q << endl;
    int old = contests[day];
    contests[day] = q + 1;
    int ts = score(d, s, c, contests, last, satis, day);
    //cout << ts << endl;
    if (ts < sc) {
      contests[day] = old;
      for (int i = day; i < d; i++) satis[i] = rec[i];
      continue;
    }
    sc = ts;
    for (int i = day; i < d; i++) rec[i] = satis[i];
    //cout << sc << endl;
  }
  //cout << sc << endl;

  for (int i = 0; i < d; i++) cout << contests[i] << endl;
}


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

int main(){
    string s;//末尾用配列
    cin >> s;
    deque<char> q;//先頭用配列
    for(int c : s ) q.push_back(c);
    int times;
    cin >> times;
    bool flip=false;
    for(int i=0; i<times; i++){
        int t_type;
        cin >> t_type;
        if(t_type==1){ // t_type=1なら前後反転
            flip=!flip;
        }else{ // t_type=2なら
            int f_type; // f_type
            char c;
            cin >> f_type >> c;
            if(flip){
                if(f_type==1){
                    f_type = 2;
                }else if(f_type==2){
                    f_type = 1;
                }
            }
            if(f_type==1){ //f_type=1なら先頭に+c
                q.push_front(c);
            }else{ //f_type=2ならsの末尾に+c，末尾用配列sに格納
                q.push_back(c);
            }
        }
    }
    if(flip) reverse(q.begin(),q.end());//backは反対から読むので
    string ans; //出力用に
    for(char c : q ) ans +=c;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++)
    for(int j=0;j<s.size();j++){
      if(s[j]=='B'){
	s.erase(j,1);
	if(j==0)break;
	s.erase(j-1,1);
	break;
      }
    }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,c,i,j,k;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    c=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(k==i || k==j )
                {
                    
                }
                else
                {
                if((a[i]+a[j])>a[k])
                c++;
                }
            }
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007

	n, m := nextInt(), nextInt()

	if abs(n-m) > 1 {
		puts(0)
		return
	}

	ans := (fact(n, mod) * fact(m, mod)) % mod
	if n == m {
		ans = (ans * 2) % mod
	}

	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func fact(n, mod int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret = (ret * i) % mod
	}
	return ret
}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("out.o", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, cnt = 0;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n ; i++) {
		for (int j = i + 1; j < n ; j++) {
			for (int k = j + 1; k < n ; k++) {
				if (a[i] != a[j] && a[k] != a[i] && a[k] != a[j] && a[i] + a[j] > a[k] && a[k] + a[i] > a[j] && a[k] + a[j] > a[i]) {
					cnt++;
				}
			}
		}
	}
	cout << cnt;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, k[111];
string s;
vector<char> c;

signed main() {
    rep(i,26) c.push_back('a'+i);
    rep(i,26) c.push_back('A'+i);
    while (1) {
        cin >> n;
        if (n==0) break;
        rep(i,n) cin >> k[i];
        cin >> s;

        int id = 0;
        string res;
        each(i,s) res.push_back(c[(find(all(c), i) - c.begin() - k[id] + 52) %52]), ++id %= n;
        cout << res << endl;
    }
}



Measured memory_bytes: 3208
#include<stdio.h>

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  while(a > 0 && c > 0){
    c -= b;
    a -= d;
  }
  if(a > 0) printf("Yes");
  else if(c <= 0) printf("Yes");
  if(c > 0) printf("No");
}

Measured memory_bytes: 1732