akhauriyash/Code-Regression huggingface dataset:
"""
前処理
"""
import numpy as np
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    ai, bi = map(int, input().split())
    """
    入力したものをそれぞれリストに格納していく、これは真似ていこう
    """
    A.append(ai)
    B.append(bi)

"""
配列に変換
"""
A = np.array(A)
B = np.array(B)

"""
処理
"""
#0からHまで
dp = np.zeros(H+1, dtype=np.int64)
dp[0] = 0

for i in range(1, H+1):
    # モンスターのHPがiである場合...
    # dp[i] ... モンスターのHPがiである時の，最小魔力合計
    dp[i] = np.amin(dp[np.maximum(i-A, 0)] + B)

"""
output
"""
print(dp[H])


Measured memory_bytes: 14504
import java.io.*;
import java.util.*;
public class Main
{
	final int zero=2001,maxn=2000;
	int n,a[],b[];
	long dp[][];
	final long mod=(long)(1e9+7);
	private void solve()throws IOException
	{
		fact();
		n=nextInt();
		a=new int[n+1];
		b=new int[n+1];
		dp=new long[zero+maxn+1][zero+maxn+1];
		for(int i=1;i<=n;i++)
		{
			a[i]=nextInt();
			b[i]=nextInt();
			dp[zero-a[i]][zero-b[i]]++;
		}
		for(int i=-maxn;i<=maxn;i++)
			for(int j=-maxn;j<=maxn;j++)
				dp[zero+i][zero+j]=(dp[zero+i][zero+j]+(dp[zero+i-1][zero+j])+(dp[zero+i][zero+j-1])%mod)%mod;
		long ans=0;
		for(int i=1;i<=n;i++)
			ans=(ans+dp[zero+a[i]][zero+b[i]])%mod;
		for(int i=1;i<=n;i++)
			ans=(ans-choose(2*a[i]+2*b[i],2*a[i])+mod)%mod;
		out.println((ans*modinv(2))%mod);
	}
	long choose(int n,int r)
	{
		return (((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod;
	}
	long fact[];
	void fact(){
		fact=new long[8000+1];
		fact[0]=1;
		for(int i=1;i<=8000;i++)
			fact[i]=(fact[i-1]*i)%mod;
	}
	long modinv(long x){
	    return modpow(x,mod-2);
	}
	long modpow(long a,long b){
	    long ret=1;
	    while(b!=0)
	    {
	        if(b%2==1)
	            ret=(ret*a)%mod;
	        a=(a*a)%mod;
	        b=b/2;
	    }
	    return ret;
	} 

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 228172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;
    string ans = s;
    int lcnt = 0, rcnt = 0;
    
    rep(i, n) {
        if (s[i] == '(') {
            lcnt++;
        }
        else if (s[i] == ')') {
            rcnt++;
            
            if (lcnt < rcnt) {
                ans = '(' + ans;
                lcnt++;
            }
        }
    }
    
    s = ans;
    lcnt = 0, rcnt = 0;
    
    rrep(i, s.length()) {
        if (s[i] == '(') {
            lcnt++;
            
            if (lcnt > rcnt) {
                ans = ans + ')';
                rcnt++;
            }
        }
        else if (s[i] == ')') {
            rcnt++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    ll n;cin>>n;
    vector<ll> a(n),cnt(200000,0);
    rep(i,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll sum=0;
    for(auto x:cnt){
        sum+=x*(x-1)/2;
    }
    rep(i,n){
        ll ans=sum;
        ans-=cnt[a[i]]*(cnt[a[i]]-1)/2;
        ans+=(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        cout<<ans<<endl;
    }

    return 0;
}


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

int main(int argc, char *argv[])
{
    int N;
    int i;
    int n = 0;
    scanf("%d\n", &N);

    for ( i = 0; i < N; i++ ){
        int l, r;
        scanf("%d %d", &l, &r);
        n += r - l + 1;
    }
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int n;
    int a;
    cin>>n>>a;
    if(n<10){
        cout<<a+100*(10-n)<<endl;
    }else{
        cout<<a<<endl;
    }
    
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int R = sc.nextInt();

        System.out.println(solve(R));
    }

    private static double solve(int R) {
        return 2 * Math.PI * R;
    }
}

Measured memory_bytes: 35996
h,w = (int(i) for i in input().split())
n = int(input())
a = [int(i) for i in input().split()]
x,num = [],0
for i in range(n):
	for j in range(a[i]):
		x.append(str(i+1))
while x != []:
	num += 1
	if num%2==1:
		print(" ".join(x[:w]))
		x = x[w:]
	else:
		print(" ".join(x[:w][::-1]))
		x = x[w:]

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

using namespace std;

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

    char c;

    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        cout << "vowel\n";
    else
        cout << "consonant\n";

    return 0;
}


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

int main(void) {
	int i,j,n;
	long long ans,tmp;
	char num[11];
	
	scanf("%s",num);
	
	ans = 0;
	for (i = 0;i < 1 << strlen(num)-1;i++) {
		n = i;
		tmp = num[0]-'0';
		for (j = 0;j < strlen(num)-1;j++) {
			if (n%2) {
				ans += tmp;
				tmp = num[j+1]-'0';
			} else {
				tmp *= 10;
				tmp += num[j+1]-'0';
			}
			n /= 2;
		}
		ans += tmp;
	}
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 128
NUM_MAX = 1000000

a = Array.new(NUM_MAX, true)

i = 2
while i*i < NUM_MAX do
	if a[i] == true then
		j = i*i
		while j < NUM_MAX do
			a[j] = false
			j += i
		end 
	end
	i += 1
end

while ns = gets do
	n = ns.to_i

	s = 0

	i = 2
	while i <= n do
		if a[i] then
			s += 1
		end
		i += 1
	end

	puts s
end

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

int compare(const void *a,const void *b) {
	return *(int*)a-*(int*)b;
}

int main(void) {
	int n,c,k;
	int *t;
	
	scanf("%d %d %d",&n,&c,&k);
	t = (int*)malloc(sizeof(int)*n);
	for (int i = 0;i < n;i++) {
		scanf("%d",&t[i]);
	}
	
	qsort(t,n,sizeof(int),compare);

	int bus = 0,s,cnt = 0,j;
	while(cnt < n) {
		bus++;
		s = t[cnt]+k;
		for (j = 0;j < c && cnt+j < n;j++) {
			if (t[cnt+j] > s) {
				break;
			}
		}
		cnt += j;
	}
	printf("%d\n",bus);

	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    double down = 0, temp;
    for (int i = 0; i < N; i++) {
        cin >> temp;
        down += (1 / temp);
    }
    cout << setprecision(10) << fixed << 1.0 / down << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (200010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,f[N][3],a[N],g[N],t[3],w[3],ans;
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	for(int i=1;i<=n+1;i++){
		int x=0,y=a[i]-a[i-1];
		if(x<y)swap(x,y);
		t[0]=max(w[0]+x,0),t[1]=min(max(w[0]+y,0),max(w[1]+x,0));
//		cout<<t[0]<<" "<<t[1]<<" ";
		int k=(t[0]>a[i]);
//		cout<<t[0]<<" "<<a[i]<<" "<<k<<endl;
		ans+=k,w[0]=t[k],w[1]=t[k+1];
	}
	cout<<ans;
}

Measured memory_bytes: 5504
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for _ in range(n)]
xya_1=0
xya_2=w
xya_3=0
xya_4=h
for _ in range(n):
  if xya[_][2]==1:
    xya_1=max(xya_1,xya[_][0])
  elif xya[_][2]==2:
    xya_2=min(xya_2,xya[_][0])
  elif xya[_][2]==3:
    xya_3=max(xya_3,xya[_][1])
  else:
    xya_4=min(xya_4,xya[_][1])
print(max(0,xya_2-xya_1)*max(0,xya_4-xya_3))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int aa[50]={0};
int main()
{
	int a,b,c=0;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>aa[i];
	}
	sort(aa,aa+a);
	for(int j=0;j<b;j++){
		c=c+aa[a-1-j];
	}
	cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  ll x;
  cin >> x;
  ll money=100;
  ll ans = 0;
  while(x > money) {
    money = money*1.01;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		for(int i = 0; i < 3; i++){
			int h = in.nextInt(), m = in.nextInt(), s = in.nextInt();
			int ans = tos(h, m, s);
			h = in.nextInt();
			m = in.nextInt();
			s = in.nextInt();
			ans = tos(h, m, s) - ans;
			h = ans / 3600; ans %= 3600;
			m = ans / 60; ans %= 60;
			s = ans;
			System.out.println(h + " " + m + " " + s);
		}	
	}

	int tos(int h, int m, int s){
		return h * 3600 + m * 60 + s;
	}
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

struct FenwickTree
{
	int N;
	vi tree;

	FenwickTree(int n)
	{
		N = n;
		tree.assign(n + 1, 0);
	}

	void update(int idx, int val)
	{
		while (idx <= N) {
			tree[idx] += val;
			idx += idx & -idx;
		}
	}

	int pref(int idx)
	{
		int ans = 0;
		while (idx > 0) {
			ans += tree[idx];
			idx -= idx & -idx;
		}
		return ans;
	}

	int rsum(int l, int r)
	{
		return pref(l) - pref(r);
	}

	void updateMax(int idx, int val)
	{
		while (idx <= N) {
			tree[idx] = max(tree[idx], val);
			idx += idx & -idx;
		}
	}

	int prefMax(int idx)
	{
		int ans = -inf;
		while (idx > 0) {
			ans = max(ans, tree[idx]);
			idx -= idx & -idx;
		}
		return ans;
	}
};

int32_t main()
{
	FIO;

	int n; cin >> n;
	int h[n + 1], a[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	FenwickTree bit(200000);

	int ans = -inf;
	for (int i = 1; i <= n; i++) {
		int m = bit.prefMax(h[i]);
		ans = max(ans, m + a[i]);

		bit.updateMax(h[i], m + a[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	ll a,b,k;
	cin >> a >> b >> k;
	if (a >= k) cout << a-k << ' ' << b << endl;
	else if (a+b >= k) cout << 0 << ' ' << a+b-k << endl;
	else cout << 0 << ' ' << 0 << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
void add_edge(vector<vector<Weight>> &g, Weight from, Weight to, bool isDirected) {
  g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

	int n; cin >> n;
  map<int,int> cnt; 
	ll ans = 0;
	rep(i,n) { int _a; cin >> _a; cnt[_a]++; ans += _a;}

	int q; cin >> q;
	rep(i, q) {
		ll b, c; cin >> b >> c;
		ans += (c-b)*cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout  << ans << en;
	}

}


Measured memory_bytes: 8116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp,mp1;
vector<pair<ll,ll>> vp,vp1;
int main()
{
	ll n;
	cin>>n;
	vector<ll> vi;
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		if(i%2 == 0)
			mp[a]++;
		else
			mp1[a]++;
		vi.push_back(a);
	}
	for(map<ll,ll>::iterator it = mp.begin();it!=mp.end();it++)
		vp.push_back(make_pair(it->second,it->first));
	for(map<ll,ll>::iterator it = mp1.begin();it!=mp1.end();it++)
		vp1.push_back(make_pair(it->second,it->first));
	if(vp.size() == 1)
		vp.push_back(make_pair(0,0));
	if(vp1.size() == 1)
		vp1.push_back(make_pair(0,0));
	sort(vp.begin(),vp.end());
	sort(vp1.begin(),vp1.end());
	pair<ll,ll> p = vp[vp.size()-1];
	pair<ll,ll> p1 = vp1[vp1.size()-1];
	pair<ll,ll> s = vp[vp.size()-2];
	pair<ll,ll> s1 = vp1[vp1.size()-2];
	if(p.second == p1.second)
	{
		cout<<n-max((p.first+s1.first),(p1.first+s.first))<<endl;
		return 0;
	}
	cout<<n-(p.first+p1.first)<<endl;
}

Measured memory_bytes: 9588
// #include <stdio.h>
// #include <string.h>
// #include <iostream>
// #include <algorithm>
// #include <math.h>
// #include <limits.h>
// #include <map>
// #include <stack>
// #include <queue>
// #include <vector>
// #include <set>
// #include <string>
// #define ll long long
// #define ull unsigned long long
// #define ms(a) memset(a,0,sizeof(a))
// #define pi acos(-1.0)
// #define INF 0x7f7f7f7f
// #define lson o<<1
// #define rson o<<1|1
// const double E=exp(1);
// const int maxn=1e6+10;
// const int mod=1e9+7;
// using namespace std;
// int a[maxn];
// bool cmp(int a,int b)
// {
// 	return a>b;
// }
// int main(int argc, char const *argv[])
// {
// 	ios::sync_with_stdio(false);
// 	int n;
// 	cin>>n;
// 	int sum=0;
// 	for(int i=0;i<n;i++)
// 	{
// 		cin>>a[i];
// 		sum+=a[i];
// 	}
// 	sort(a,a+n,cmp);
// 	int res=sum/n;
// 	if(sum%n)
// 		res++;
// 	int rres;
// 	if(n&1)
// 		rres=a[n/2];
// 	else
// 		rres=(a[n/2]+a[n/2+1])/2;
// 	// if(a[0]<=0)
// 	// {
// 	// 	cout<<0<<endl;
// 	// 	return 0;
// 	// }
// 	// cout<<"-------"<<res<<"------"<<rres<<endl;
// 	int ans=0;
// 	int ans1=0;
// 	for(int i=0;i<n;i++)
// 	{
// 		ans=ans+(a[i]-res)*(a[i]-res);
// 		ans1=ans1+(a[i]-rres)*(a[i]-rres);
// 	}
// 	cout<<min(ans,ans1)<<endl;
// 	// else
// 	// 	cout<<a[0]<<endl;
// 	return 0;
// }
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int a[maxn];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int res=INT_MAX;
	// sort(a,a+n);
	for(int i=-100;i<=100;i++)
	{
		int x=0;
		for(int j=0;j<n;j++)
			x+=(a[j]-i)*(a[j]-i);
		res=min(res,x);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0
def suc(time):
  if time == []:
    return 'over'
  else:
    now = n-2
    while now >= 0:
      if time[now] == 0:
        time[now] = 1
        break
      else:
        time[now] = 0
        now -= 1
    if now >= 0:
      return time
    else:
      return 'over'
time = [0 for _ in range(n-1)]
while time != 'over':
  add = 0
  st = 0
  for i in range(n):
    try:
      if time[i] == 1:
        add += int(s[st:i+1])
        st = i+1
    except:
      #i==n
      add += int(s[st:])
  ans += add
  time = suc(time)
print(ans)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc058/tasks/abc058_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    REP(i, a.length()) {
        cout << a[i];
        if (i < (int)b.length()) {
            cout << b[i];
        }
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	ll a, b, c; 
/* BIEN CUC BO END*/

void solve(){	
	cin >> a >> b >> c;
	cout << min(b/a,c);
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

// n の素因数を (素因数, 個数) のペアで列挙して返す。O(sqrt(N))
map<i64, int> getPrimeFactors(i64 n)
{
    map<i64, int> pf;
    for (i64 i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            pf[i] += 1;
            n /= i;
        }
    }
    if (n != 1) pf[n] = 1;
    return pf;
}

constexpr int MOD = int(1e9) + 7;

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

    unordered_map<int, int> cnt;

    for (int i = 2; i <= N; ++i) {
        for (const auto  e : getPrimeFactors(i)) {
            cnt[e.first] += e.second;
        }
    }

    i64 ans = 1;
    for (const auto e : cnt) {
        ans = (ans * (e.second + 1)) % MOD;
    }

    cout << (ans) << endl;

    return 0;
}


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

using namespace std;

int main(){

  int h,w;

  cin>>h>>w;

  vector<string> cond(h);

  for(int i=0;i<h;++i)
	cin>>cond[i];

  for(int i=0;i<h;++i){
	int c = 0;
	for(int j=0;j<w;++j){
	  if(cond[i][j]=='.' && c == 0)
		cout<<-1;
	  else if(cond[i][j]=='c'){
		cout<<0;
		c=1;
	  }
	  else if(cond[i][j]=='.' && c != 0){
		cout<<c;
		c++;
	  }
	  if(j != w-1)
		cout<<' ';
	}
	cout<<endl;
  }
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="RRR")cout << 3;
  else if(s=="SSS")cout << 0;
  else if(s=="RSS"||s=="RSR"||s=="SSR"||s=="SRS")cout<<1;
  else cout<<2;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
  cin>>n>>m;
  int min=0;
  int kurikaesu=0;
  if(n>=m){
    kurikaesu=n;
    min=m;
  }else{
    kurikaesu=m;
    min=n;
  }
  for(int i=0;i<kurikaesu;i++){
    cout<<min;
  }
  cout<<endl;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, k;
    vector<int> v;
    cin >> a >> b >> k;

    int tmp = 1;
    for (int i = 1; i <= min(a, b); i++)
    {
        if (a % i == 0 && b % i == 0)
        {
            v.push_back(i);
        }
    }
    int size = v.size();
    cout << v[size - k] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	
	int a, b;
	cin >> a >> b;
	vector<vector<char>> grid(103, vector<char>(103));
	int acnt = 0;
	int bcnt = 0;
	if (a > b)
	{
		for (int i = 1; i < 101; ++i)
		{
			for (int j = 1; j < 101; ++j)
			{
				grid[i][j] = '#';
			}
		}
		bcnt++;
		bool flag = false;
		for (int i = 1; i < 98; i+=4)
		{
			if (flag)
			{
				break;
			}
			for (int j = 1; j < 98; j += 4)
			{
				if (a - acnt == 0)
				{
					flag = true;
					break;
				}
				for (int k = i; k < i + 3; k++)
				{
					for (int k1 = j; k1 < j + 3; ++k1)
					{
						grid[k][k1] = '.';
					}
				}
				acnt++;
				if (b-bcnt> 0)
				{
					grid[i + 1][j + 1] = '#';
					bcnt++;
				}
			}
		}
	}
	if (b >= a)
	{
		for (int i = 1; i < 101; ++i)
		{
			for (int j = 1; j < 101; ++j)
			{
				grid[i][j] = '.';
			}
		}
		acnt++;
		bool flag = false;
		for (int i = 1; i < 98; i += 4)
		{
			if (flag)
			{
				break;
			}
			for (int j = 1; j < 98; j += 4)
			{
				if (b -bcnt == 0)
				{
					flag = true;
					break;
				}
				for (int k = i; k < i + 3; k++)
				{
					for (int k1 = j; k1 < j + 3; ++k1)
					{
						grid[k][k1] = '#';
					}
				}
				bcnt++;
				if (a - acnt> 0)
				{
					grid[i + 1][j + 1] = '.';
					acnt++;
				}
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	for (int i = 1; i < 101; ++i)
	{
		for (int j = 1; j < 101; ++j)
		{
			cout << grid[i][j];
		}
		cout << endl;
	}
	system("pause");
}

Measured memory_bytes: 504
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	for i := 0; i < len(s); i++ {
		for j := 0; j < len(s); j++ {
			t := s[:i] + s[j:]
			if t == "keyence" {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 1280
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

ll binarysearch(ll *a,ll n,ll k,ll r)
{
    ll l=1,mid;
    ll p=k;
    while(l<r)
    {   
        ll x=0;
        k=p;
        mid=(l+r)/2;
        for(ll i=n-1;i>=0;i--)
        {   
            ll c=((*(a+i))+mid-1)/mid;
            
            if(c==1)
            break;
            k=k-c+1;
            if(k<0)
            {
                x=1;
                break;
            }    
        }
        if(x==1)
        l=mid+1;
        else
        r=mid;
    }
    return l;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       ll n,k;
       cin>>n>>k;
       
       ll a[n];
       for(ll i=0;i<n;i++)
       cin>>a[i];
       sort(a,a+n);
       ll max=a[n-1];
       ll ans=binarysearch(a,n,k,max);
       cout<<ans<<"\n";
    }
}



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

using namespace std;

int main()
{
  uint64_t R, G, B, N;
  cin >> R >> G >> B >> N;
  
  uint64_t X = max(max(R, G), B), Y = -1, Z = min(min(R, G), B);
  if ((X == R && Z == G) || (X == G && Z == R)) { Y = B; } else
  if ((X == R && Z == B) || (X == B && Z == R)) { Y = G; } else
  if ((X == G && Z == B) || (X == B && Z == G)) { Y = R; }
  
  uint64_t count = 0;
  for (uint64_t x = 0; x <= N/ X; ++x) {
    uint64_t M = N - x * X;
    for (uint64_t y = 0; y <= M / Y; ++y) {
      uint64_t L = M - y * Y;
      if (L % Z == 0) { ++count; }
    }
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x = x2 - x1;
	int y = y2 - y1;
	cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
}


Measured memory_bytes: 256
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()

	factorialInit(max(n, m))
	if n == m {
		fmt.Fprintln(wr, fac[n]*fac[m]*2%mod)
	} else if abs(n-m) == 1 {
		fmt.Fprintln(wr, fac[n]*fac[m]%mod)
	} else {
		fmt.Fprintln(wr, 0)
	}
}

const mod = 1000000007

var fac, ifac, inv []int

func factorialInit(n int) {
	fac = make([]int, n+1)
	ifac = make([]int, n+1)
	inv = make([]int, n+1)

	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[1] = 1

	for i := 1; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % mod
		inv[i+1] = mod - inv[mod%(i+1)]*(mod/(i+1))%mod
		ifac[i+1] = ifac[i] * inv[i+1] % mod
	}
}

func comb(a, b int) int { return (fac[a] * ifac[b] % mod) * ifac[a-b] % mod }
func perm(a, b int) int { return fac[a] * ifac[a-b] % mod }


Measured memory_bytes: 4192
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long A;
    int count_odd = 0;
    for(int i=0;i<N;i++){
        cin >> A;
        if(A%2 == 1) count_odd++;
    }

    if(count_odd%2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
X, N = [int(x) for x in input().split()]
if N:
    P  = [int(x) for x in input().split()]
    P = set(P)
else:
    P = set()
best = (float('inf'), )
for i in range(0, 102):
    if i not in P:
        best = min(best, (abs(i - X), i))
print(best[1])

Measured memory_bytes: 61840
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    
    for (ll tc=1;tc<=tt;tc++){
        string n;
        cin>>n;
        reverse(all(n));
        
        if (n[0]=='3'){
            cout<<"bon\n";
        }
        else if (n[0]=='0' or n[0]=='1' or n[0]=='6' or n[0]=='8')
        cout<<"pon\n";
        else
        cout<<"hon\n";
        
    }
    
	return 0;
}

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

int main() {
  string str;
  while (cin >> str) {
    if (str == "-") break;
    int m, h;
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      str = str.substr(h, str.size() - h) + str.substr(0, h);
    }
    cout << str << endl;
  }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
vector<int> k, p;
vector<vector<int>> s;
int N, M;

void dfs(vector<int> x, int &ans) {
    if (x.size() == N)
    {
        for (int i = 0; i < M; i++)
        {
            int c = 0;
            for (int j = 0; j < N; j++)
            {
                if (s[i][j] && x[j])
                {
                    c++;
                }
            }
            if (c % 2 != p[i])
            {
                return;
            }
        }
        ans++;
        return;
    }
    
    x.push_back(1);
    dfs(x, ans);
    x.pop_back();
    x.push_back(0);
    dfs(x, ans);
    x.pop_back();

}

int main() {
    cin >> N >> M;
    k.resize(M);
    p.resize(M);
    s.resize(M);
    for (int i = 0; i < M; i++)
    {
        cin >> k[i];
        s[i].resize(N);
        for (int j = 0; j < k[i]; j++)
        {
            int x;
            cin >> x;
            --x;
            s[i][x] = 1;
        }
        
    }
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }    

    vector<int> x;
    int ans = 0;
    dfs(x, ans);
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int H[301], W[301];
    using namespace std;

    int r = 0;
    while(1){
        cin >> H[r] >> W[r];

        if (H[r] == 0 && W[r] == 0){
        break;
        }
        ++r;
    }

    for (int i = 0; H[i] != 0 && W[i] != 0; ++i){
        for (int y = 0; y < H[i]; ++y){
            for (int x = 0; x < W[i]; ++x){
                cout << "#";

            }
                cout << endl;
        }
        cout << endl;
    }

    return 0;
}




Measured memory_bytes: 3088
N = [5, 1, 3, 4, 6, 2]
S = [2, 6, 3, 4, 1, 5]
E = [3, 2, 6, 1, 5, 4]
W = [4, 2, 1, 6, 5, 3]

die = gets.split.map(&:to_i)

str = gets.chomp

while str != ""
d = str.slice!(0)

temp = Array.new(6)

case d

when "N"
for j in 1..6
temp[N[j-1]-1] = die[j-1]
end

when "S"
for j in 1..6
temp[S[j-1]-1] = die[j-1]
end

when "E"
for j in 1..6
temp[E[j-1]-1] = die[j-1]
end

when "W"
for j in 1..6
temp[W[j-1]-1] = die[j-1]
end
end

die = temp
end


puts die[0]









Measured memory_bytes: 6876
w = gets.to_i
n = gets.to_i
d = Array.new
w.times do |i|
  d.push(i+1)
end
n.times do
  line = gets
  s = line.split(",").map(&:to_i)
  d[s[0]-1], d[s[1]-1] = d[s[1]-1], d[s[0]-1]
end
w.times do |i|
  puts d[i]
end

Measured memory_bytes: 6104
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	int i;
	int a, b, c;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> b >> c;
		if (a < b) 
			swap(a,b);
		if (a < c)
			swap(a, c);

		if (a*a == b*b + c*c) {
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using p = pair<int, int>;

int main() {
  string S;
  cin >> S;
  if (S=="ARC") cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}

Measured memory_bytes: 3604
N,X = map(int,input().split())
L = list(map(int, input().split()))

D_i, count = 0,0
for l in L:
  D_i1 = D_i+ l
  #print(D_i1)
  if D_i1<=X: count+=1
  D_i = D_i1
print(count+1)

Measured memory_bytes: 2940
program dice_in_line
  implicit none
  integer :: n, k, p(200000) = 0, s(0:200000) = 0, i, m = 0
  read(*,*) n, k
  read(*,*) p(1:n)
  do i = 1, n
    s(i) = s(i-1)+p(i)
  end do
  do i = k, n
    m = max(m,s(i)-s(i-k)+k)
  end do
  write(*,'(i0)',advance='no') m/2
  if (mod(m,2) == 1) write(*,'(a)',advance='no') ".5"
  write(*,*)
end program dice_in_line

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
int main(){ _;
  ll N;cin>>N;
  for(ll h=1;h<=3500;h++)
    for(ll n=h;n<=3500;n++){
      if(4*h*n-N*n-N*h<=0)continue;
      if((N*h*n)%(4*h*n-N*n-N*h)==0){
	ll w=(N*h*n)/(4*h*n-N*n-N*h);
	cout<<h<<" "<<n<<" "<<w<<endl;
	return 0;
      }
    }
}


Measured memory_bytes: 256
s = input()
n = len(s)
a = []
i = 0
ct = 0
for i in range(n):
  a.append(int(s[i]))
i = -1

while ct < 100000000000:
  n = len(a)
  i += 1
  if i >= n-1: break
  if a[i] == 0 and a[i+1] == 1:
    a.pop(i)
    a.pop(i)
    ct += 1
    i -= 2
    if i <= 1: i=-1
    continue
  elif a[i] == 1 and a[i+1] == 0:
    a.pop(i)
    a.pop(i)
    ct += 1
    i -= 2
    if i <= 1 :i = -1
    
print(ct*2)

Measured memory_bytes: 3964
from math import ceil
def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    C = list(map(int,input().split()))
    A.sort(reverse=True)
    C.sort()
    def chk(x):
        cnt = 0
        for i in range(N):
            cnt += max(ceil(A[i]-x/C[i]), 0)
            if cnt > K:
                return False
        return True
    ng, ok = -1, 10**12
    while ok - ng > 1:
        m = (ok+ng)//2
        if chk(m):
            ok = m
        else:
            ng = m
    print(ok)
if __name__ == "__main__":
    main()

Measured memory_bytes: 114140
/*input
18 477
324 31 27 227 9 21 41 29 50 34 2 362 92 11 13 17 183 119


*/

#include <iostream>

using namespace std;

const int MOD = 1e9 + 7, MAXN = 103, MAXX = 505;

int add(int a, int b) 
{ return (a += b) -= (a >= MOD ? MOD : 0); }

int sub(int a, int b) 
{ return (a -= b) += (a < 0 ? MOD : 0); }

int mul(int a, int b) 
{ return (int) ((long long) a * b % MOD); }

// int bpow(int a, int p)
// {
// 	int ans = 1;
// 	for (; p > 0; p >>= 1) {
// 		if (p & 1) ans = mul(ans, a);
// 		a = mul(a, a);
// 	}
// 	return ans;
// }

int /*fact[MAXX], */C[MAXX][MAXX];
int N, X, sheets[MAXX];
int dp[MAXX][MAXX];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> X;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		++sheets[x];
	}

	// fact[0] = 1;
	// for (int i = 1; i <= X; ++i) fact[i] = mul(fact[i - 1], i);
	for (int i = 0; i <= X; ++i) C[i][0] = 1;
	for (int i = 1; i <= X; ++i) for (int j = 1; j <= i; ++j) C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);

	dp[0][0] = 1;
	for (int x = X; x >= 1; --x) {
		for (int i = X; i >= 1; --i) {
			for (int j = 1; j <= i; ++j) {
				for (int y = x * i; y <= X; ++y) {
					dp[i][y] = add(dp[i][y], mul(dp[i - j][y - x * j], C[i][j]));
				}
			}
		}

		for (int _ = 0; _ < sheets[x]; ++_) {
			dp[0][0] = 0;
			for (int i = 1; i <= X; ++i) {
				for (int y = x * i; y <= X; ++y) if (dp[i][y]) {
					dp[i][y] = mul(dp[i][y], y - (x - 1) * i);
				}
			}
		}
	}

	int ans = 0;

	for (int i = 1; i <= X; ++i) {
		for (int y = i; y <= X - i + 1; ++y) {
			// cout << i << ' ' << y << ": " << dp[i][y];
			dp[i][y] = mul(dp[i][y], C[X + 1 - y][i]);
			// cout << ' ' << dp[i][y] << endl;
			if ((X - y) & 1) ans = sub(ans, dp[i][y]);
			else ans = add(ans, dp[i][y]);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N, P; 
	string S; 
	cin >> N >> P >> S; 
	long long ans = 0LL; 
	if(P == 2 || P == 5){
		for(int i = 0; i < N; i++){
			if((S.at(i) - '0') % P == 0){
				ans += (long long) i + 1; 
			}
		}
		cout << ans << endl; return 0; 
	}
	long long cnt[10010] = {}; cnt[0] ++; 
	reverse(S.begin(), S.end()); 
	long long pow = 1LL; 
	long long acc = 0LL; 
	for(int i = 0; i < N; i++){
		acc += pow * (S.at(i) - '0'); 
		acc %= P; 
		cnt[acc] ++; 
		pow *= 10; pow %= P; 
	}
	for(int i = 0; i < P; i++){
		ans += cnt[i] * (cnt[i] - 1) / 2; 
	}
	cout << ans << endl; 
}

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

int main(){
  int k;
  string s;
 
  cin >> k >> s;
  
  int cnt=0;
  for(int i=0;i<s.length();i++){
    cnt++;
  }

  if(cnt<=k){
   cout<<s<<endl;
  }
  else{
    for(int i=0;i<k;i++){
      cout<<s[i];
  }
     cout<<"..."<<endl;
  }
  
return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

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

    cin >> n;
    
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n, m;
  cin >> n >> m;

  vector<int> h(n) ;
  REP(i,n)  cin >> h[i];

  vec a(m), b(m);
  REP(i, m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vector<bool> c(n, true);
  REP(i, m){
    if(h[a[i]] > h[b[i]]){
      c[b[i]] = false;
    }
    else if(h[a[i]] < h[b[i]]){
      c[a[i]] = false;
    }
    else{
      c[a[i]] = c[b[i]] = false;
    }
  }

  int ans = 0;
  REP(i, n){
    if(c[i]) ans++;
  }

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

Measured memory_bytes: 5572
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,c,k=mp()
t=sorted([int(input()) for i in range(n)])
count=1
f=t[0]
ans=1
for i in range(1,n):
    count+=1
    d=t[i]-f
    if d>k or count>c:
        ans+=1
        count=1
        f=t[i]

print(ans)


Measured memory_bytes: 8280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Biscuit_Generator
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt16(input[0]);
            int b = Convert.ToInt16(input[1]);
            int t = Convert.ToInt16(input[2]);
            int times = (t - t % a) / a;
            Console.WriteLine(times * b);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
n, q = map(int,input().split())
queue = []
for i in range(n):
    proccess = list(input().split())
    queue.append([proccess[0],int(proccess[1])])
cnt = 0
time = 0

while cnt < n:
    if queue[0][1] <= q:
        time += queue[0][1]
        print(queue[0][0] + " " +str(time))
        cnt += 1
        del queue[0]
    elif queue[0][1] > q:
        time += q
        queue[0][1] -= q
        queue.append(queue.pop(0))


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

int main(){
  ll N;cin >> N;
  vector<ll> S(N+1,0);
  for(int i=0;i<N;i++){
    ll a;cin >> a;
    S[i+1] = S[i] + a;
    //cout << S[i+1] << " ";
  }
  //cout << endl;
  sort(S.begin(),S.end());
  ll sum=0;
  ll i=0;
  for(ll j=0;j<=N;j++){
    if(j==N){
      sum += (j-i)*(j-i+1)/2;
    }else if(S[j]!=S[j+1]){
      sum += (j-i)*(j-i+1)/2;
      //cout << j << " " << sum << endl;
      i = j + 1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4796
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a%b << " " << setiosflags(ios::fixed)<<setprecision(15)<< ((double)a / (double)b) << endl;
}

Measured memory_bytes: 1240
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
const int maxn=100005;
int n;
int main(){
	int type=0,lst,ans=1,x;
	scanf("%d%d",&n,&lst);
	REP(i,2,n){
		scanf("%d",&x);
		if(type==0){
			if(x<lst)type=1,lst=x;
			else if(x>lst)type=2,lst=x;
		}else if(type==1){
			if(x>lst)++ans,type=0,lst=x;
			else if(x<lst)lst=x;
		}else{
			if(x<lst)++ans,type=0,lst=x;
			else if(x>lst)lst=x;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256