akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	void doIt() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(Math.min(n * a, b));
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define ull unsigned long long
#define base 203
using namespace std;
char s[20];
map<int,int>mp;
bool cmp(char a,char b){
	return a<b;
}
int main(){
	int n;
	scanf("%d",&n);
	ull ans=0;
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		ull Hash=0;
		int l=strlen(s+1);
		sort(s+1,s+1+l,cmp);
		for (int j=1;j<=l;j++)
		Hash=Hash*base+s[j];
		ans+=mp[Hash];
		mp[Hash]++;
	}
	printf("%llu\n",ans);
	return 0;
} 

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int k=gi();
	    int s=gi();
	    int c=0;
	    for (int i=0; i<=k;i++) {
		    for (int j=0; j<=k;j++) {
                if (i+j<=s && s<=i+j+k) {
                    c++;
                }
		    }
	    }

	    	System.out.println(c);
	    
        //System.out.println(e);
//        if (xo>w || yo>h) {
//        	System.out.print(0);
//        }else {
//        	System.out.print((h-yo)*(w-xo));
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35284
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

struct Edge{
	int to; ll cost;
	Edge(){}
	Edge(int to,int cost):to(to),cost(cost){}
};

vector<Edge> G[100010];
int n,m;

ll d[2][100010];

int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b; ll c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back(Edge(b,c));
		G[b].push_back(Edge(a,c));
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			d[i][j]=1e18;
		}
	}
	d[0][0]=0; // 偶奇の場合分けが必要そう
	queue<pair<int,int> > q;
	q.push(make_pair(0,0));
	bool ok=true;
	while(q.empty()==false){
		pair<int,int> now=q.front();
		q.pop();
		int od=now.first; int v=now.second;
		for(auto p:G[v]){
			int tv=p.to;
			ll co=p.cost;
			if(d[1-od][tv]==1e18){
				d[1-od][tv]=co-d[od][v];
				q.push(make_pair(1-od,tv));
			}
			else{
				if(d[1-od][tv]!=co-d[od][v]){ // 辻褄が合わない
					ok=false;
					break;
				}
			}
		}
		if(ok==false){
			cout << 0 << endl;
			return 0;
		}
	}
	if(d[1][0]!=1e18){
		if(d[1][0]<=0){
			cout << 0 << endl;
			return 0;
		}
		if(d[1][0]%2==1){
			cout << 0 << endl;
			return 0;
		}
		ll fi=d[1][0]/(ll)2;
		ll mi=1e18;
		for(int i=0;i<n;i++){
			mi=min(mi,d[0][i]);
		}
		ll mi1=1e18;
		for(int i=0;i<n;i++){
			mi1=min(mi1,d[1][i]);
		}
		mi=-mi+(ll)1;
		mi1--;
		if(mi<=fi&&fi<=mi1){
			cout << 1 << endl;
			return 0;
		}
		else{
			cout << 0 << endl;
			return 0;
		}
	}
	else{
		ll mi=1e18;
		for(int i=0;i<n;i++){
			mi=min(mi,d[0][i]);
		}
		ll mi1=1e18;
		for(int i=0;i<n;i++){
			mi1=min(mi1,d[1][i]);
		}
		mi=-mi+(ll)1;
		mi1--;
		if(mi<=mi1){
			cout << mi1-mi+1 << endl;
			return 0;
		}
		else{
			cout << 0 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 9856
#include<stdio.h>

int main(){
  int d,r,a,b;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  double x=a,y=b;
  f=x/y;
  printf("%d %d %.5f\n",d,r,f);
  return 0;
}


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

#define INF 1e9 + 5

// for using in pairs
#define F first
#define S second

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

#define int long long

void solve(int tc)
{
	int n, d;
	cin >> n >> d;

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		x = abs(x);
		y = abs(y);

		if (x * x + y * y <= d * d)
			ans++;

	}
	cout << ans << "\n";
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<lli> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<vector<lli>> dp(n,vector<lli>(n,0));
	for(int l=1;l<=n;l++){
		for(int i=0;i+l-1<n;i++){
			int j=i+l-1;
			if(l==1){
				dp[i][j]=a[i];
				continue;
			}
			dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
	}
	cout<<dp[0][n-1]<<endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n;

int func(int n){
    int rtn = 0;
    for(ll i=7;i<=n;i*=10){
        rtn++;
    }
    return rtn;
}

ll pow10(int a){
    ll rtn=1;
    Rep(i,a){
        rtn*=10;
    }
    return rtn;
}

int func2(int n,vector<int> a){
    int rtn = 0;
    int z = a.size();
    for(int b=0;b<z;++b){
        for(int c=(b!=0);c<z;++c){
            for(int d=(c!=0);d<z;++d){
                for(int e=(d!=0);e<z;++e){
                    for(int f=(e!=0);f<z;++f){
                        for(int g=(f!=0);g<z;++g){
                            for(int h=(g!=0);h<z;++h){
                                for(int i=(h!=0);i<z;++i){
                                    for(int j=(i!=0);j<z;++j){
                                        
                                         if(a[b]*pow10(8)+a[c]*pow10(7)+a[d]*pow10(6)+a[e]*pow10(5)+a[f]*pow10(4)+a[g]*pow10(3)+a[h]*pow10(2)+a[i]*pow10(1)+a[j]*pow10(0)<=n){
                                            
                                            rtn++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    return rtn;
}

int main() {
    cin >> n;
    int res = 0;
    //res = func(n);
    vector<int> a = {0,3,5,7};
    vector<int> b = {0,5,7};
    vector<int> c = {0,3,7};
    vector<int> d = {0,3,5};
    vector<int> e = {0,7};
    vector<int> f = {0,5};
    vector<int> g = {0,3};
    put(func2(n,a)-func2(n,b)-func2(n,c)-func2(n,d)+func2(n,e)+func2(n,f)+func2(n,g)-1);
    return 0;
}


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

long f(int x){
	return x*x;
}

long area(int n, int b){
	return b*f(n);
}

int main(void) {

	int d, i;
	
	while( scanf("%d", &d) != EOF ) {
		int bit = 600 / d;
		long s=0;
		
		for(i=0; i<bit-1; i++) 
			s+= area( d*(i+1) , d );
		
		
		printf("%ld\n", s);
		
	}
	
	return 0;
}
	
	

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

int main(){
    int S,h,m,s;
    cin >> S;
    h = S / 3600;
    m = (S - h*3600) / 60;
    s = S - h*3600 - m*60 ;
    cout << h <<":"<< m <<":"<< s <<endl;
    return 0;
}


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

int main(){
    double n,m,d;
    cin >> n >> m >> d;
    double ans = 2*(n-d)*(m-1)/(n*n);
    double zero = 0.0;
    if(d == zero) ans /= 2;
    cout << fixed << setprecision(8) << ans << endl; 
    cin >> n;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n,x,y);
    vector<int> distance(n,0);
    vector<vector<int>> graph(n);
    graph[x-1].push_back(y-1);
    graph[y-1].push_back(x-1);
    for(int i=0;i<n;i++){
        if(i!=0)graph[i].push_back(i-1);
        if(i!=n-1)graph[i].push_back(i+1);
    }
    int a;
    for(int i=0;i<n-1;i++){
        queue<int> next;
        vector<int> subdistance(n,-1);
        next.push(i);
        subdistance[i]=0;
        while(!next.empty()){
            a=next.front();
            next.pop();
            rep(j,graph[a].size()){
                if(subdistance[graph[a][j]]==-1){
                    next.push(graph[a][j]);
                    subdistance[graph[a][j]]=subdistance[a]+1;
                }
            }    
        }
        for(int j=i+1;j<n;j++){
            distance[subdistance[j]]++;
        }
    }
    for(int i=1;i<n;i++){
        out(distance[i]);
    }
}

Measured memory_bytes: 3872
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	nums := make(map[int]int)
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		nums[a]++
		nums[b]++
	}

	for _, v := range nums {
		if v%2 == 1 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
	int a, b;
	char op;
	int wa, sa;

	scanf("%d", &a);
	scanf(" %c", &op);
	scanf("%d", &b);

	wa = a + b;
	sa = a - b;

	if (op == '+') {
		printf("%d", wa);
	}
	else {
		printf("%d", sa);
	}

	
	return 0;

}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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






int main() {
    ll k, a, b;
    scanf("%lld %lld %lld", &k, &a, &b);
    if(a + 2 >= b || k <= a){
        printf("%lld\n", k + 1LL);
        return 0;
    }
    k -= a + 1;
    ll ans = b + (b - a) * (k / 2) + (k & 1);
    printf("%lld\n", ans);
}

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

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) cnt++;
    }
    
    cout << cnt << endl;
}


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

int main(){
  int N;
  cin>>N;
  double x;
  string u;
  double total=0;
  double rate=380000.0;
  for (int i=0; i<N; i++){
    cin>>x>>u;
    if (u=="JPY"){
      total+=x;
    } else {
      total+=x*rate;
    }
  }
  
 cout<<total<<endl;
}
  

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

#ifdef _TEST
void test();
#endif

void Main()
{
	int N;
	cin>>N;
	N=1000 - (N%1000);
	if(N==1000)N=0;
	cout<<N<<_n;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
#ifndef _TEST
	Main();
#else
#endif
	return 0;
}

#ifdef _TEST
int test(){

}
#endif

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



int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

 string n;
  cin>>n;
  long long int res=0;
  long long int res1=0;
cout<<fixed<<setprecision(15);
  for(int i=0;i<n.length();i++){
      res1+=n[i] - 48;
		
      
  }
  if(res1%9==0 ){
      cout<<"Yes\n";
  }
  else{
      cout<<"No\n";
  }
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

ll ans[100];


ll ryuka(int n){
  if(ans[n]!=0) return ans[n];
  ll ret;
  if(n==0){
    ans[n]=2;
    ret=2;
  }
  else if(n==1){
    ans[n]=1;
    ret=1;
  }
  else{
    ret=ryuka(n-1)+ryuka(n-2);
  }
  ans[n]=ret;
  return ret;
}


int main() {
  for(int i=0;i<100;i++)ans[i]=0;
 ll n;
  cin>>n;
  cout<<ryuka(n)<<endl;
}

Measured memory_bytes: 3604
#include <stdlib.h>
#include <queue>
#include <string>
#include <iostream>
using namespace std;

struct process{
	string name;
	int time;
};

void print_process_queue(queue<process> output, int num);
queue<process> calculate_round_robbin(queue<process> input, int time);
int main(){
	int num;
	int time;

	cin >> num;
	cin >> time;

	queue<process> works;
	for(int i = 0; i < num; ++i){
		process work;
		cin >> work.name;
		cin >> work.time;
		works.push(work);
	}
	queue<process> output = calculate_round_robbin(works, time);

	print_process_queue(output, num);

	return 0;
}

queue<process> calculate_round_robbin(queue<process> input, int time){
	int totalTime = 0;
	queue<process> output;
	while(!input.empty()){
		if(input.front().time > time){
			totalTime += time;
			input.front().time -= time;
			input.push(input.front());
			input.pop();
		}else{
			totalTime += input.front().time;
			input.front().time = totalTime;
			output.push(input.front());
			input.pop();
		}
	}
	return output;
}

void print_process_queue(queue<process> output, int num){
	for(int i = 0; i < num; ++i){
		cout << output.front().name << " " << output.front().time << endl;
		output.pop();
	}
}

Measured memory_bytes: 6020
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
using namespace std;
const int maxn=1e4+50;
int n,a,b,sum,ans;
int main(){
    while(scanf("%d%d%d",&n,&a,&b)!=EOF){
        //vector<int> v;
        sum=0;
        for(int i=1;i<=n;i++){
            int cnt=0;
            ans=i;
            do{
                //cout<<i<<endl;
                int temp=ans%10;
                cnt+=temp;
                ans=ans/10;

            }while(ans!=0);
            if(cnt<=b&&cnt>=a)
                sum+=i;
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

int main()
{
    int X, num_500, num_5;
    cin >> X;

    num_500 = X / 500;
    X -= num_500 * 500;
    num_5 = X / 5;

    cout << num_500 * 1000 + num_5 * 5 << endl;
}

Measured memory_bytes: 256
N, X = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)

cnt = 0
(1 ... N).each do |i|
  d = (As[i] + As[i - 1]) - X
  if d > 0
    cnt += d
    As[i] = [As[i] - d, 0].max
  end
end
puts cnt

Measured memory_bytes: 11148
#include<stdio.h>
#include<math.h>
int main(void){
    int i,n;
    int s[1000];
    double m,sum,a;
    while(1){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        a=0;
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            sum+=s[i];
        }
        m=sum/n;
        for(i=0;i<n;i++){
            a+=pow(s[i]-m,2.0);
        }
        a/=n;
        printf("%f\n",pow(a,0.5));
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <stdint.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int32_t> A;

  int64_t sum = 0;
  for (int n=1; n<=N; ++n) {
    int64_t a;
    cin >> a;
    A.push_back(a-n);
    sum += a-n;
  }

  sort(A.begin(),A.end());
  
  int b = A[N/2];

  cerr << b << endl;

  int64_t ans = 0;
  for (auto a : A) {
    ans += abs(a-b);
  }

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


Measured memory_bytes: 1400
import sys
sys.setrecursionlimit(10**5)

def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write

    N, M, L = map(int, readline().split())
    *K, = map(int, readline().split())
    *S, = map(int, readline().split())
    su = [0]*(M+1)
    r = 0
    for i in range(M):
        su[i+1] = r = r + S[i]
    K.sort()
    memo = [[-1]*N for i in range(N)]
    def calc(a, b):
        sa = K[a]; sb = K[b]
        if not sa < sb:
            sa, sb = sb, sa
        return (su[sb] - su[sa-1]) // L
    def dfs(i, a, b):
        if i == N:
            return calc(a, b)
        if memo[a][b] != -1:
            return memo[a][b]
        r = min(dfs(i+1, a, i) + calc(b, i), dfs(i+1, b, i) + calc(a, i))
        memo[a][b] = r
        return r
    write("%d\n" % dfs(1, 0, 0))
solve()



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

int main(){
    int n;
    cin>>n;
    int a[n];
    int pos=0,neg=0;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]=a[i]-(i+1);
        if(a[i]>0)pos++;
        else if(a[i]<0)neg++;
        sum+=abs(a[i]);
    }
    sort(a,a+n);
    //i thought almost correct
    int mid=a[n/2];
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(mid-a[i]);
    }
    cout<<ans;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if ((A + B) < (C + D)) cout << "Right" << endl;
	if ((A + B) == (C + D)) cout << "Balanced" << endl;
	if ((A + B) > (C + D)) cout << "Left" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
    d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
#define G(a)((r=A[a]+A[P[a]]+C[a])%k?r:0)
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33464
#include <math.h>
#include <iostream>
#include <utility>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <set>


    

int main()
{
  	int Nmax = 100000;
    char String[Nmax];
    int N;
    int i,j,k;
    int len;   // 文字列の長さ
   

      
    // 入力読込
    // 文字列
    scanf("%s", String);

 
    
    // 晴れ(Sunny)、くもり(Cloudy)、雨(Rainy) 
    
    if( String[0] == 'S'){
      printf("Cloudy");
    }
    else if( String[0] == 'C'){
      printf("Rainy");
    }
    else if(String[0] == 'R'){
      printf("Sunny");
    }
    
  
  return 0;
   

}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

res = 0
ret = 0
for i in range(1,n+1):
    res += i
    if res >= n:
        ret = i
        break

ans = []
while n:
    if n-ret < 0:
        ret -= 1
    else:
        ans.append(ret)
        n -= ret
        ret -= 1

for i in ans:
    print(i)

Measured memory_bytes: 80380
def main():
    N,K=map(int,input().split())
    a_ls=list(map(int,input().split()))
    f_ls=list(map(int,input().split()))
    
    a_ls.sort()
    f_ls.sort()
    f_ls.reverse()
    
    def can_eat_by(x):
        cost_after_training=list(map(lambda item: x//item, f_ls))
        sum=0
        for i in range(N):
            if a_ls[i]>cost_after_training[i]:
                sum+=a_ls[i]-cost_after_training[i]
        return sum<=K
    
    left=-1
    right=10**12
    prev_x=-10
    # 二分探索でtest(x)がtrueとなるxの最小値を探索する
    # left = rightとなるまで繰り返す
    while left + 1 < right:
      mid = (left+right)//2
      
      # mid秒で食べられる場合は探索範囲の右端をmidにする
      if can_eat_by(mid):
        right = mid
      # mid秒で食べられない場合は探索範囲の左端をmidにする
      else:
        left = mid
     
    answer = right
    print(answer)

main()


Measured memory_bytes: 136432
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int k,x;
  cin>>k>>x;

  for(int i=-1000000;i<=1000000;i++){
    if(x-k+1<=i&&i<=x+k-1)cout<<i<<" ";
  }

  return 0;
}


Measured memory_bytes: 256
from math import gcd

N = int(input())
# 常にy座標の方を正にする
zero = 0
d = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue
    # 最大公約数で割って互いに素である状態にする（既約分数にする）
    g = gcd(a, b)
    a //= g
    b //= g
    # 常にbを正の状態に保つ
    if b < 0:
        a = -a
        b = -b
    if b == 0 and a == -1:
        a = 1

    if a > 0:
        if (a, b) in d:
            d[(a, b)][0] += 1
        else:
            d[(a, b)] = [1, 0]
    else:
        if (b, -a) in d:
            d[(b, -a)][1] += 1
        else:
            d[(b, -a)] = [0, 1]
MOD = 10**9+7
ans = 1
for (a, b), (k, l) in d.items():
    ans *= (pow(2, k, MOD)-1) + (pow(2, l, MOD)-1) + 1
    ans %= MOD
ans += zero
ans -= 1
print(ans%MOD)


Measured memory_bytes: 60476
#include <iostream>

using namespace std;

int main(){
  char c;
  cin >> c;
  switch(c){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    default:
      break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod  = 1000000000+7;
char g[1000+5][1005];
ll dp[1005][1005];
int main(){
int n, m;
cin >> n >> m;
for(int i=0; i<n; i++)
    for(int j=0; j<m; j++)
        cin >> g[i][j];

for(int i=0;i<n; i++) {
      if (g[i][0]=='#') break;
    dp[i][0] = 1;
}
for(int j=0; j<m; j++){
    if(g[0][j]=='#') break;
     dp[0][j] = 1;
}

for(int i=1; i<n; i++){
    for(int j=1; j<m; j++){
            if(g[i][j]=='#') continue;
        dp[i][j] = (dp[i-1][j]+dp[i][j-1]) %mod;
        //cout << i<<" "<<j <<" "<< dp[i][j] <<" ";
    }
    //cout << endl;
}
cout << dp[n-1][m-1];
return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ll
constexpr int cN = ( 1 << 20 ) + 1;
ll pool0[cN];
ll pool1[cN];
ll poolCount[cN];

ll fib( ll a )
{
	ll b = 1; ll c = 1;
	REP( i, a - 2 )
	{
		ll d = c;
		c = ( c + b ) % cMOD;
		b = d;
	}
	return c;
}

template <typename T>
T mod_pow(T x, T n, T mod)
{
	T res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

int main()
{
	memset( pool0, 0, sizeof( pool0 ) );
	memset( pool1, 0, sizeof( pool1 ) );
	memset( poolCount, 0, sizeof( poolCount ) );
	
	ll n;
	cin >> n;
	vector<ll> v(n,0);

	ll sum = 0;
	REP(i,n)
	{
		cin >> v[i];
		sum ^= v[i];
	}

	ll left = 0;
	ll count = 0;
	REP(i,cN) pool0[i] = 1;
	REP(i,n)
	{
		left ^= v[i];
		if( left == 0 ) ++count;
		else
		{
			pool0[left] = ( pool0[left] + pool1[left] * ( count - poolCount[left] ) ) % cMOD;
			poolCount[left] = count;
			pool1[left] = ( pool1[left] + pool0[left] ) % cMOD;
		}
	}

	ll ans = 0;
	if( sum == 0 )
	{
		ans = mod_pow( 2ll, count - 1, cMOD );
		REP(i, cN)
		{
			if( i == 0 ) continue;
			ans = ( ans + pool1[i] ) % cMOD;
		}
	}
	else
	{
		ans = pool0[sum];
	}
	
	cout << ans << endl;

	return 0;
}

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

int main() {
  int n, x, sum = 0;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        x = gcd(gcd(i, j), k);
        sum += x;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
#define mod 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl
using namespace std;
using ll = long long int;

void jets(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll dp[3002][3002];

ll solve(vector<int>& vec, int i, int j){
	if(i>j)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll op1=vec[i]+min(solve(vec,i+2,j),solve(vec,i+1,j-1));
	ll op2=vec[j]+min(solve(vec,i,j-2),solve(vec,i+1,j-1));
	return dp[i][j]=max(op1,op2);
}


int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int n;
    cin>>n;
    vector<int> vec(n);
    ll sum=0;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++){
    	cin>>vec[i];
    	sum+=vec[i];
    }
    ll res=solve(vec,0,n-1);
    cout<<res-(sum-res);
    return 0;
}

Measured memory_bytes: 74192
// D - Sum of Large Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N, K, MOD = 1'000'000'007;
	cin>>N>>K; ++N,--K;
	ll n = (N*(N+1) - K*(K+1)) / 2;
	ll n2 = (N*(N+1)*(2*N+1) - K*(K+1)*(2*K+1)) / 6;
	cout<< (N*n - n2 + N-K) % MOD <<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  vector<int> p;
  
  scanf("%d", &n);
  scanf("%d", &k);
  
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    p.push_back(t);
  }
  
  std::sort(p.begin(), p.end());
  
  int ans = 0;
  for (int i=0 ; i <k; i++) {
  	ans += p.at(i);
  }
  //for (int i = 0; i< n; i++) {
  //	cout << p.at(i) << endl;
  //}
  cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>

using namespace std;

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           1e9
#define   rush()        int T;scanf("%d",&T);while(T--)
#define   debug         puts("debug")

typedef   pair<int,int> P;


int main() {
/*
	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
*/
	ll n,m,ans;
	scanf("%lld %lld",&n,&m);
	ans = abs((n-2)*(m-2));
	printf("%lld\n",ans);
}




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

#define M 8000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M /* your task */; }
int h2(int key){ return (key % (M-1)) +1/* your task */; }

int find(char str[]){

    /* your task */

  int i=0,j;
  while(1){
    j =(h1(getKey(str)) + i*h2(getKey(str)))%M;
    
    if(strcmp(H[j],str) == 0) {
      return 1;
    }
     else if((H[j][0] == '\0')||(i>=M)) return 0;
     else i++;
  }
}

int insert(char str[]){

    /* your task */

  int i=0,j;
  
  while(1){
    j = (h1(getKey(str)) + i*h2(getKey(str)))%M;
    if(H[j][0] == '\0'){
      strcpy(H[j], str);
      return 0;
    }
    else i++;
     
  
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    //  for(i=0;i<=M;i++){
    // if(H[i][0]!='\0') printf("%s\n",H[i]);
    //}



    
    return 0;
}



Measured memory_bytes: 111116
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }

    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    UnionFind uf;
    int n,m;cin >> n >> m;
    uf.init(n+1);
    for (int i = 0; i < m; i++) {
        int x,y,z;cin >> x >> y >> z;
        x--,y--;
        uf.unite(x,y);
    }
    vector<bool> f(n+1,false);
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        if(f[uf.find(i)]) continue;
        else{
            ans++;
            f[uf.find(i)]=true;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int H, W;
    cin>>H>>W;
    int N;
    cin>>N;
    int a[N];
    for(int i=0;i<N;++i){
        cin>>a[i];
    }
    int index = 0;
    int ans[H][W];
    for(int i=0;i<H;++i){
        if(i%2==0){
            for(int j=0;j<W;++j){
                ans[i][j] = index+1;
                a[index]--;
                if(a[index]==0)index++;
            }
        }
        else{
            for(int j=W-1;j>=0;--j){
                ans[i][j] = index+1;
                a[index]--;
                if(a[index]==0)index++;
            }
        }
    }
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int r,g,b,n,i,j,ans=0;
    cin >> r >> g >> b >> n;

    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            int a = n-(r*i + g*j);
            if(a >= 0 && a%b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
    int c[5][5];
    rep(i,3) rep(j,3) scanf("%d",&c[i][j]);
    int sum = 0, tmp;
    rep(i,3) rep(j,3) sum += c[i][j];
    int ok = 1;
    if(sum%3 != 0) ok = 0;
    sum /= 3;
    rep(i,3){
        tmp = c[0][i]+c[1][(i+1)%3]+c[2][(i+2)%3];
        if(sum!=tmp) ok=0;
    }
    rep(i,3){
        tmp = c[0][2-i]+c[1][(2-i-1+3)%3]+c[2][(2-i-2+3)%3];
        if(sum!=tmp) ok=0;
    }
    
    if(ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 1616
from collections import Counter
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
v = []
for i in range(n):
    for j in range(n):
        if i == j: continue
        x, y = xy[j]
        px, py = xy[i]
        v.append((x-px, y-py))
num = Counter(v).most_common(1)[0][1] if v else 0
print(n - num)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
bool isPalindromic(int n){
    vi digits(5);
    rep(i, 0, 5){
        digits[i]=n%10;
        n/=10;
    }
    if(digits[0]==digits[4] and digits[1]==digits[3]){
        return true;
    }
    return false;
}
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vi digits(5);
    int a,b,all=0;
    cin >> a >> b;
    rep(i, a, b+1){
        if(isPalindromic(i)){
            all++;
        }
    }
    cout << all << endl;
    return 0;
}

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

int main() {
  string s;

  cin >> s;

  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
   int d,n,x,a[100],b[100],i, sum=0;
   scanf("%d",&n);
   scanf("%d %d",&d,&x);
   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      b[i]=a[i];
   }
   for(i=0;i<n;i++){
      sum++;
      while(a[i]+1<=d){
         sum++;
         a[i]+=b[i];
      }
   }
   sum+=x;
   printf("%d\n",sum);
   return 0;
}

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

typedef long long ll;

#define rep(i, n) for (int i = 1; i < (int)(n); i++)

int main() { 
    ll N, N_10=10, N_9=9, N_8=8, mod=1000000007, ans;
    cin >> N;

    rep(i, N) {
        N_10 = (N_10 * 10) % mod;
        N_9  = (N_9  *  9) % mod;
        N_8  = (N_8  *  8) % mod;
    }

    ans = (N_10 - N_9 * 2 + N_8) % mod;
    ans = (ans+mod)%mod;
    cout <<  ans << "\n";
    return 0;
}


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

dp = [0] + [10**9]*(N-1)

for i in range(1, N):
  k = min(i, K)
  for j in range(1, k+1):
    cost = abs(H[i-j] - H[i])
    dp[i] = min(dp[i], dp[i-j]+cost)
    if cost == 0:
      break

print(dp[N-1])

Measured memory_bytes: 52448
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
min_ = int((N//1.08)-1)
for v in range(min_, min_+100):
    if (int(v * 1.08) == N):
        print(v)
        exit()

print(':(')


Measured memory_bytes: 42264
S = input()
alp = 'abcdefghijklmnopqrstuvwxyz'
if len(S) < 26:
    for char in alp:
        if not char in S:
            print(S+char)
            exit()
else:
    for i in range(1,26)[::-1]:
        if S[i-1] < S[i]:
            for j in range(i,26)[::-1]:
                if S[j] > S[i-1]:
                    print(S[:i-1]+S[j])
                    exit()
    print(-1)

Measured memory_bytes: 61944
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> a[i]; }

	vector<int> b(N + 1, 0);
	for (int i = N; i > 0; --i) {
		int sum = 0;
		for (int j = 1; j * i <= N; ++j) {
			sum += b[j * i];
		}
		if (sum % 2 == 0) {
			if (a[i] % 2 == 1) { b[i] += 1; }
		} else {
			if (a[i] % 2 == 0) { b[i] += 1; }
		}
	}

	bool ok = true;
	for (int i = 1; i <= N; ++i) {
		int sum = 0;
		for (int j = 1; j * i <= N; ++j) {
			sum += b[j * i];
		}
		if ((sum % 2) != (a[i] % 2)) {
			ok = false;
			break;
		}
	}

	if (!ok) {
		cout << -1 << endl;
		return 0;
	}

	vector<int> res;
	for (int i = 1; i <= N; ++i) {
		if (b[i] > 0) { res.push_back(i); }
	}
	cout << res.size() << endl;
	for (int i = 0; i < res.size(); ++i) {
		cout << res[i] << (i < res.size() - 1 ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 3064
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    if a == b == c:
        if a % 2 == 0:
            print(-1)
        else:
            print(0)
    else:
        cnt = 0
        while True:
            if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
                cnt += 1
                a, b, c = (a + b) // 2, (b + c) // 2, (a + c) // 2
            else:
                print(cnt)
                exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	vector<int> p(N);
	for (int i = 0; i < N; i++)
	{
		cin >> p[i];
	}

	sort(p.begin(), p.end());

	int ans = 0;
	for (int i = 0; i < N - 1; i++)
	{
		ans += p[i];
	}
	ans += (p[N - 1] / 2);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
from math import *

def comTime(x):
  return ceil(x/10) * 10

def solve(_l):
  s = 0
  l =sorted(_l, key=lambda x: (10-x) % 10, reverse=True)
  s += sum(map(comTime,l[1:])) + l[0]
  return s
  
_l = [int(input()) for _ in range(5)]
print(solve(_l))


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

vector<vector<long long>> dp;
vector<long long> a;
int n;

long long f(int s, int e) {
	if (s < 1 || e > n)
		return 0;
	if (dp[s][e] == -1) {
		if (((n + 1) - (s + e)) & 1) {
			//second player
			if (s == e)
				dp[s][e] = -a[s];
			else
				dp[s][e] = min(f(s + 1, e) - a[s], f(s, e - 1) - a[e]);
		} else {
			//first player
			if (s == e)
				dp[s][e] = a[s];
			else
				dp[s][e] = max(f(s + 1, e) + a[s], f(s, e - 1) + a[e]);
		}
	}
	return dp[s][e];
}

int main() {
	cin >> n;
	a.resize(n + 1);
	dp.resize(n + 1, vector<long long>(n + 1, -1));
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	cout << f(1, n);

	return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <stdio.h> 
#include <algorithm>
using namespace std;

long long int a[3];

int main()
{
	int max1 = 0, sum = 0, result = 0;
	for(int i=0;i<3;i++)
	{
		scanf("%lld", &a[i]);
		if(a[i]%2==0)
		{
			printf("0\n");
			return 0;
		}		
	}	
	sort(a, a+3);
	long long int ans = a[0]*a[1];
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
/// c.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    ll n;
    fi>>n;
    static ll C[555][555];
    for (int i = 0;i <= 50;++i)
        for (int j = 0;j <= i;++j)
            C[i][j] = (!i || !j ? 1 : C[i - 1][j] + C[i - 1][j - 1]);
    int was = 0;
    function < vi(ll) > F = [&](ll n)
    {
        if (!n)
            return vi{};
        vi C = F((n - 1) / 2);
        int n1 = C.size() / 2;
        int n2 = C.size();
        vi ans;
        for (int i = 0;i < n1;++i)
            ans.pb(C[i]);
        int suka = was + 1;
        ++was;
        ans.pb(was);
        if (!(n & 1))
        {
            ++was;
            ans.pb(was);
            ans.pb(was);
        }
        for (int i = n1;i < n2;++i)
            ans.pb(C[i]);
        ans.pb(suka);
        return ans;
    };
    auto ans = F(n);
    int sz = (ans.size());
    fo << (ans.size()) << '\n';
    for (auto it : ans)
        fo << it << ' ';
    fo << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int l = scanner.nextInt();
        int r = scanner.nextInt();
        boolean b = r-l>=2019;
        l %= 2019;
        r %= 2019;
        if (l>r||b) {
            System.out.println(0);
        }else {
            int min = 2019;
            for (int i=l;i<r;i++){
                for (int j=i+1;j<=r;j++){
                    min = Math.min(min,(i*j)%2019);
                }
            }
            System.out.println(min);
        }


    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
long long a[100010][3]; 
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 4992
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def dfs(s, count):
    if len(s) == n:
        print(s)
        return

    for z in range(count + 1):
        dfs(s + a[z], count + 1 if z == count else count)


dfs("", 0)





Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{  cin>>s1>>s2;
   int a=s1.size(),b=s2.size();
   if(a>b)
   {
   	 for(int i=0;i<b;i++)
   	   cout<<s1[i]<<s2[i];
   	 cout<<s1[a-1];
   }
    if(a<b)
   {
   	 for(int i=0;i<a;i++)
   	   cout<<s1[i]<<s2[i];
   	 cout<<s1[b-1];
   }
    if(a==b)
   {
   	 for(int i=0;i<b;i++)
   	   cout<<s1[i]<<s2[i];
   }
	return 0;
}


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

int main() {
    int n, ans = 0;
    cin >> n;

    vector<int> odd(0);
    for (int i = 1; i <= n; i++)
    {
        if (i % 2 == 1)
        {
            odd.push_back(i);
        }
    }
    // for (int i = 0; i < odd.size(); i++)
    // {
    //     cout << odd[i] << " ";
    // }
    // cout << endl;

    for (int i = 0; i < odd.size(); i++)
    {
        int cnt = 0;
        for (int j = 1; j <= odd[i]; j++)
        {
            
            if (odd[i] % j == 0)
            {
                cnt++;
            }
        }
        if (cnt == 8)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256