akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
			int N = nextInt();
			ArrayList<Integer> list = nextIntArray();
			double sum = 0;
			for(int i = 0; i < N; i++){
				sum += (double)1 / list.get(i);
			}
			myout(1 / sum);
	}
	//Method addition frame start




	//Method addition frame end
}


Measured memory_bytes: 33272
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#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 endl 			"\n"
#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--)
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;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(10);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();
	int h;
	cin >> h;
	int f = 1, s = 0;
	while (h)
	{
		s += f;
		f *= 2;
		h = h >> 1;
	}
	cout << s;

	return 0;
}

Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<vector<int>> g(n);
  vector<int> erased(n);
  vector<int> degA(n), degB(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> que;
  for (int i = 0; i < n; i++) {
    for (int j : g[i]) {
      if (s[j] == 'A') degA[i]++;
      if (s[j] == 'B') degB[i]++;
    }
    if (degA[i] == 0 || degB[i] == 0) que.push(i), erased[i] = 1;
  }
  while (que.size()) {
    int cur = que.front();
    que.pop();
    for (int nxt : g[cur]) if (nxt != cur && !erased[nxt]) {
      if (s[cur] == 'A') degA[nxt]--;
      if (s[cur] == 'B') degB[nxt]--;
      if (degA[nxt] == 0 || degB[nxt] == 0) que.push(nxt), erased[nxt] = 1;
    }
  }
  for (int i = 0; i < n; i++) if (!erased[i]) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 12880
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
    
def resolve():
    N,M=pin()
    print(N*(N-1)//2+M*(M-1)//2)
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 3"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """13 3"""
        output = """81"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """0 3"""
        output = """3"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

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

class dice
{
    int l1, l2, l3, l4, l5, l6;
    int top;

public:
    dice()
    {
        std::cin >> l1 >> l2 >> l3 >> l4 >> l5 >> l6;
    }

    void turnNorth()
    {
        top = l2;
        l2 = l6;
        l6 = l5;
        l5 = l1;
        l1 = top;
    }

    void turnEast()
    {
        top = l4;
        l4 = l6;
        l6 = l3;
        l3 = l1;
        l1 = top;
    }

    void turnSouth()
    {
        top = l5;
        l5 = l6;
        l6 = l2;
        l2 = l1;
        l1 = top;
    }

    void turnWest()
    {
        top = l3;
        l3 = l6;
        l6 = l4;
        l4 = l1;
        l1 = top;
    }

    void print()
    {
        std::cout << top << std::endl;
    }
};

int main()
{
    dice dice;

    std::string order;

    std::cin >> order;

    for (auto& it : order)
    {
        if      (it == 'N') dice.turnNorth();
        else if (it == 'E') dice.turnEast();
        else if (it == 'S') dice.turnSouth();
        else if (it == 'W') dice.turnWest();
    }

    dice.print();
}


Measured memory_bytes: 3172
#include <iostream>
#include <array>
int main(){
  int r;
  int D;
  std::array<int,11> x_2000;
  std::cin >> r >> D >> x_2000[0];
  for(auto i=0;i<10;++i){
    x_2000[i+1] = r*x_2000[i] - D;
  }
  for(auto i=1;i<11;++i){
    std::cout << x_2000[i] << std::endl;
  }
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back

using namespace std;

const int Nmax=100000;

vector<int> g[Nmax],rG[Nmax],bct[Nmax];
int idom[Nmax],semi[Nmax],us[Nmax],id[Nmax],rId[Nmax],par[Nmax],mn[Nmax],anc[Nmax];

void AddEdge(int a,int b){
	g[a].PB(b);
	rG[b].PB(a);
}

int Find(int v){
	if(anc[v]==-1)
		return v;
	int a=Find(anc[v]);
	if(id[semi[mn[anc[v]]]]<id[semi[mn[v]]])
		mn[v]=mn[anc[v]];
	return anc[v]=a;
}

void Link(int c,int p){
	anc[c]=p;
}

void Dfs(int v,int p,int& i){
	if(id[v]!=-1)
		return;
	id[v]=i;
	rId[i++]=v;
	par[v]=p;
	for(int c:g[v])
		Dfs(c,v,i);
}

void Calc(int n){
	REP(i,n){
		semi[i]=i;
		id[i]=-1;
		mn[i]=i;
		anc[i]=-1;
	}
	int tmp=0;
	Dfs(0,-1,tmp);
	for(int i=n-1;i>0;i--){
		int w=rId[i];
		for(int v:rG[w]){
			Find(v);
			if(id[semi[mn[v]]]<id[semi[w]])
				semi[w]=semi[mn[v]];
		}
		bct[semi[w]].PB(w);
		for(int v:bct[par[w]]){
			Find(v);
			us[v]=mn[v];
		}
		bct[par[w]].clear();
		Link(w,par[w]);
	}
	FOR(i,1,n){
		int w=rId[i];
		if(semi[w]==semi[us[w]])
			idom[w]=semi[w];
		else
			idom[w]=idom[us[w]];
	}
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int main(){
	int n=read(),m=read();
	REP(i,m){
		int s=read()-1,t=read()-1;
		AddEdge(s,t);
	}
	Calc(n);
	int q=read();
	REP(i,q){
		int r=read()-1;
		if(idom[r]==0)
			printf("%d\n",r+1);
		else
			printf("%d\n",idom[r]+1);
	}
}

Measured memory_bytes: 24132
#include<iostream>

using namespace std;

int main()
{
	int a[4],b[4];
	
	for(;cin >> a[0];)
	{
		int hit=0,blow=0;
		
		cin >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3] ;
		
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<4;j++)
			{
				if(b[i]==a[j])
				{
					if(i==j)
						hit++;
					else
						blow++;
				}
			}
		}
		
		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int s = 0, t = 0, u = 0;
    for (i = 0; i < n; i++)
        if (a[i] % 2 == 1)
            s++;
        else if (a[i] % 4 == 0)
            t++;
        else
            u++;
    if ((u == 0 && s - t > 1) || (u > 0 && s - t > 0))
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

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

int main(){
    int n, i, buf = 0, c = 0, ans = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(i=0; i<n; i++){
        if(a[i] == buf){
            c++;
        }else{
            buf = a[i];
            if(c%2 == 1){
                ans++;
            }
            c = 1;
        }
    }
    if(c%2 == 1){
        ans++;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 100 + 7;

int n, m;
string s[N];

bool read () {
	if (scanf("%d%d", &n, &m) != 2)
		return false;
	static char buf[N];
	forn(i, n){
		scanf("%s", buf);
		s[i] = buf;
	}
	return true;
}

int dp[N][N];

void solve() {
	forn(i, n) forn(j, m) dp[i][j] = INF;
	dp[0][0] = (s[0][0] != '.');
	forn(i, n) forn(j, m){
		if (i + 1 < n) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i + 1][j] != s[i][j]));
		if (j + 1 < m) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j + 1] != s[i][j]));
	}
	dp[n - 1][m - 1] += (s[n - 1][m - 1] != '.');
	printf("%d\n", dp[n - 1][m - 1] / 2);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

int main(){
    int a, b, c, amari;
    bool flag = false;

    cin >> a >> b >> c;
    amari = a % b;

    for (int i = 1; i <= 100; i++){
        if ((amari * i ) % b == c){
            cout << "YES";
            return 0;
        }
    }

    cout << "NO";

    return 0;
}

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

int main(){
  long long N, K, R, S, P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  long long sum = 0;
  for(int i=0; i<T.size(); i++){
    if(T[i]=='s')sum+=R;
    if(T[i]=='r')sum+=P;
    if(T[i]=='p')sum+=S;
  }
  bool x=true, y=true,z=true;
  for(int i=K; i<T.size(); i++){
    if(T[i-K]==T[i]){
      if(T[i]=='s'){sum-=R;T[i]='z';}
      if(T[i]=='r'){sum-=P;T[i]='z';}
      if(T[i]=='p'){sum-=S;T[i]='z';}
    }
  }
  cout << sum << endl;
  return 0;
}

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

int num_div2(int x) {
    int ret = 0;
    while(x%2 == 0) {
        x /= 2;
        ret++;
    }
    return ret;
}

int main() {
    int n, a, ans = 100;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        ans = min(ans, num_div2(a));
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
int a[30];
ll n;
int main()
{
	int i,cnt=0;
	n=read();
	for(;n;n/=10)a[++cnt]=n%10;
	int sum=0,mx=0;
	for(i=cnt;i;i--){
		sum+=a[i];
		if(a[i]>0)mx=max(mx,sum-1+9*(i-1));
	}
	mx=max(mx,sum);
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    ll n;
    cin >> n;
    ll ans = LINF;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ans = min(ans, i + n / i - 2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np

N, M, X = map(int, input().split())
C = [None]*N
A = [None]*N
for i in range(N):
    line = list(map(int, input().split()))
    C[i] = line[0]
    A[i] = np.array(line[1:])

choose = [True, False]

min_price = -1

for s in range(1 << N):
    price = 0
    knowledge = np.zeros(M)
    for i in range(N):
        if s >> i & 1:
            knowledge += A[i]
            price += C[i]
    if np.any(knowledge < X):
        continue
    if min_price == -1:
        min_price = price
    min_price = min(min_price, price)

if min_price == -1:
    print(-1)
else:
    print(min_price)


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

int main(){    
    int N; cin >> N;
    vector<int> ans(4, 0);

    for (int i = 0; i < N; i++)
    {
        string c;
        cin >> c;

        if (c == "AC") ans[0] += 1;
        else if (c == "WA") ans[1] += 1;
        else if (c == "TLE") ans[2] += 1;
        else if (c == "RE") ans[3] += 1;
    }
    
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
int main()
{
    int n, as = 0, s = 0, ans = INT_MAX;
    cin >> n;
    vector<int> w(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &w[i]);
        as += w[i];
    }
    for(int i = 1; i < n; i++){
        s += w[i-1];
        ans = min(abs(as - 2*s), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string tmp, tmp1;
  bool ok = true;
  map<string, int> amap;
  cin>>tmp;
  amap[tmp]++;
  tmp1 = tmp;
  for(int i=1;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]>0) ok = false;
    if(tmp[0]!=tmp1[tmp1.size()-1]) ok = false;
    amap[tmp]++;
    tmp1 = tmp;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>x>>y>>z;
c=y;a=z;b=x;
cout<<a<<" "<<b<<" "<<c;
}


Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
ans=[]
if sum(t for t in a if t>0)>sum(-t for t in a if t<0):
    i=0
    while a[i]<0:i+=1
    for j in range(n):
        if a[j]>0and i!=j:
            a[i]+=a[j]
            ans+=[(j+1,i+1)]
    for j in range(n):
        if a[j]<0:
            a[j]+=a[i]
            ans+=[(i+1,j+1)]
    for i in range(1,n):
        ans+=[(i,i+1)]
else:
    i=0
    while a[i]>0:i+=1
    for j in range(n):
        if a[j]<0and i!=j:
            a[i]+=a[j]
            ans+=[(j+1,i+1)]
    for j in range(n):
        if a[j]>0:
            a[j]+=a[i]
            ans+=[(i+1,j+1)]
    for i in range(n,1,-1):
        ans+=[(i,i-1)]
print(len(ans))
for t in ans:print(*t)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m2,m4,mo,c;
  cin>>n;
  m2=m4=mo=0;
  for(int i=0;i<n;++i){
    cin>>c;
    if(c%4==0)m4++;
    else if(c%2)mo++;
    else m2++;
  }
  cout<<(m4>=mo||(!m2&&m4+1>=mo)?"Yes":"No");
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans;
Pll a[200100];
struct Edge { Pll to; LL cost; };
string str;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
class BIT{
public:
	vector<LL> Bit;
	LL M;

	BIT(LL M) :
		Bit(vector<LL>(M + 1, 0)), M(M) {}

	LL sum(LL i) {
		LL s = 0;
		while (i>0) {
			s += Bit[i];
			i -= (i&(-i));
		}
		return s;
	}
	LL sum(LL i, LL j) {
		return sum(j) - sum(i-1);
	}
	void add(LL i, LL x) {
		while (i <= M) {
			Bit[i] += x;
			i += (i&(-i));
		}
	}
};
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i + 1].first;
		a[i + 1].first -= m;
		a[i + 1].first += a[i].first;
		a[i].second = i+1;
	}
	a[n].second = n+1;
	sort(a, a + n + 1);
	BIT bit(n+1);
	rep(i, n + 1) {
		ans += n + 1 - a[i].sec - bit.sum(a[i].sec, n + 1);
		bit.add(a[i].second, 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
# include <iostream>
# include <map>
# define pf push_front
# define pb push_back
# define mp make_pair
# define pr printf
# define se second
# define si size()
# define sc scanf
# define fi first
# define er erase
# define be begin
# define ss size
# define Int __int64
# define INF 100000000000000008
# define MOD 1000000007
# define MN 500500
# define eps 0.0000000000000000018
# define mem(a) memset(a,0,sizeof(a))
# define cpy(b,a) memcpy(b,a,sizeof(a))
#define fast ios_base::sync_with_stdio(false)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;

int main() {
map<int,int>m;
std::map<int,int>::iterator it;

	int n,i,num;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>num;
		if(m[num]){
			it=m.find(num);
			m.erase(it);
		}
		else m[num]=1;
	}
	cout<<m.size();
	return 0;
}
/* and its only us now */


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

int main(){
    vector<int> N(10,0);
    int cnt = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='B' && cnt>0){
            cnt--;
        }
        else if(s[i]=='0'){
            N[cnt] = 0;
            cnt++;
        }
        else if(s[i]=='1'){
            N[cnt] = 1;
            cnt++;
        }
    }
    
    for (int i = 0; i < cnt; i++)
    {
        cout << N[i];
    }
    
    cout << endl;
}


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

int n,t;
int d[100],f[100];
bool graph[100][100], visited[100];

void dfs(int v){
    visited[v]=true;
    t++;
    d[v]=t;

    for(int v2=0; v2<n; v2++){
        if(graph[v][v2] && visited[v2]==false) dfs(v2);
    }

    t++;
    f[v]=t;
}

int main(void){
    cin >> n;
    t=0;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            graph[i][j]=false;
        }
    }
    for(int i=0; i<n; i++){
        int v,k; cin >> v >> k;
        for(int j=0; j<k; j++){
            int w; cin >> w;
            graph[v-1][w-1]=true;
        }
    }

    for(int i=0; i<n; i++) visited[i]=false;
    for(int i=0; i<n; i++){
        if(visited[i]==false) dfs(i);
    }
    for(int i=0; i<n; i++){
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end();
const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen(".in","r",stdin);
   freopen(".out","w",stdout);
}
const ll INF = 1e9 + 7;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const int  INTmx = (int)1e9;
const int N = 2e5 + 100;
ll dp[N][3];
ll a[N];
ll b[N];
ll c[N];
int main()
{
    //file();
    boos();
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for(int i = 2;i <= n;i++)
    {
        dp[i][0] = max(dp[i - 1][1],dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0],dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0],dp[i - 1][1]) + c[i];
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define pb emplace_back

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

ll dp[110][100010];

int main()
{
    int n,W;
    cin >> n >> W;
    int w[n],v[n];
    rep(i,n) cin >> w[i] >> v[i];
    fill(dp[0],dp[0]+100010,1e18);
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100010; j++){
            if(j < v[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
        }
    }
    int ans = 0;
    rep(i,100010) if(dp[n][i] <= W) ans = i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;

/**
 * Seven Puzzle
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Map<Integer, Integer> move = new HashMap<>();
		Deque<State> que = new ArrayDeque<>();
		State s = new State(new int[]{0, 1, 2, 3, 4, 5, 6, 7}, 0, 0);

		que.offer(s);
		move.put(s.id, 0);

		while (!que.isEmpty()) {
			State p = que.poll();
			while (p.hasNext()) {
				State n = p.next();
				if (!move.containsKey(n.id)) {
					que.offer(n);
					move.put(n.id, n.move);
				}
			}
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			System.out.println(move.get(s2i(line)));
		}
	}

	static int s2i(String s) {
		int ret = 0;
		for (int i = 0; i < s.length(); i += 2) {
			ret *= 10;
			ret += s.charAt(i) - '0';
		}
		return ret;
	}
}

class State {

	static int SIZE = 8;
	static final int[][] SWAP = {
			{1, 4},     //0
			{0, 2, 5},  //1
			{1, 3, 6},  //2
			{2, 7},     //3
			{0, 5},     //4
			{1, 4, 6},  //5
			{2, 5, 7},  //6
			{3, 6},     //7
	};

	int id;
	int[] pz;
	int zero;
	int move;
	int idx = 0;

	State(int[] pz, int zero, int move) {
		this.pz = pz;
		this.zero = zero;
		this.move = move;
		id = 0;
		for (int i = 0; i < SIZE; i++) {
			id *= 10;
			id += pz[i];
		}
	}

	State next() {
		int[] _pz = new int[SIZE];
		System.arraycopy(pz, 0, _pz, 0, SIZE);
		_pz[zero] = pz[SWAP[zero][idx]];
		_pz[SWAP[zero][idx]] = 0;
		this.idx++;
		return new State(_pz, SWAP[zero][idx - 1], move + 1);
	}

	boolean hasNext() {
		return idx < SWAP[zero].length;
	}
}

Measured memory_bytes: 33280
using System;
using System.Linq;

namespace CSharpSample01
{

	class Program
	{

		static void Main(string[] args)
		{
			var N = Console.ReadLine();

			if (N.Where(x => x == '7').Any())
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 26580
n=int(input())
a=list(map(int,input().split()))
SUM=sum(a)
hlf=SUM//2
cnt=0
res=float('inf')
for i in range(n):
    cnt+=a[i]
    rst=SUM-cnt
    if cnt==hlf:
        print(0)
        exit()
    res=min(abs(rst-cnt),res)
print(res)

Measured memory_bytes: 26396
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N); unordered_map<int, int> L, R;
    REP(i, 0, N) {
        cin >> A[i];
        L[i + A[i]]++;
        R[i - A[i]]++;
    }

    ll ans = 0;
    for (auto l : L) {
        ans += (ll)l.second * R[l.first];
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N,K;
vi V;

signed main() {
    cin>>N>>K;
    rep(i,0,N) {
        int v; cin>>v; V.pb(v);
    }

    int p=min(K,N);
    int ans=0;
    for(int a=0;a<=p;a++) {
        
        for(int b=0;b<=p-a;b++) {
            priority_queue<int,vector<int>,greater<int>> q;
            rep(i,0,a) {
                q.push(V[i]);
            }
            int c=K-a-b;
            rep(j,0,b) {
                q.push(V[N-j-1]);
            }

            while(!q.empty() and c>0) {
                
                int t=q.top();
                if(t>=0) break;
                else{
                    q.pop();
                    c--;
                }
            }

            int ret=0;
            while(!q.empty()) {
                ret+=q.top();
                q.pop();
            }
            ans=max(ans,ret);

        }
    }

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





Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def _cmb(N, mod):
    N1 = N + 1
    fact = [1] * N1
    inv = [1] * N1

    for i in range(2, N1):
        fact[i] = fact[i-1] * i % mod

    inv[N] = pow(fact[N], mod-2, mod)
    for i in range(N-1, 1, -1):
        inv[i] = inv[i+1]*(i+1) % mod

    def cmb(a, b):
        return fact[a] * inv[b] * inv[a-b] % mod
    return cmb

def resolve():
    K = int(input())
    s = input()
    ls = len(s) - 1
    mod = 10**9+7

    cmb = _cmb(ls+K, mod)

    ans = 0
    for i in range(K+1):
        ans += cmb(ls+i, ls) * pow(25, i, mod) * pow(26, K - i, mod)
        ans %= mod
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 106176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define mp make_pair
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

ll cnt[10][10],N,ans;

ll top_dec(ll n){
    while(n/10>0)n/=10;
    return n;
}

ll bot_dec(ll n){
    return n%10;
}

int main(void){
    cin >> N;
    rep(i,N+1)cnt[top_dec(i)][bot_dec(i)]++;
    for(ll i=1;i<=9;i++)for(ll j=1;j<=9;j++)ans+=cnt[i][j]*cnt[j][i];
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
def rec(A, s, d, f):
    if d == f:
        return
    A.append(s)
    rec(A, s + "3", d+1, f)
    rec(A, s + "5", d+1, f)
    rec(A, s + "7", d+1, f)

N = int(input())
digit = int(math.log10(N)) + 1
A = []
rec(A, "", 0, digit+1)
Asize = len(A)
cnt = 0
for i in range(Asize):
    if "3" in A[i] and "5" in A[i] and "7" in A[i] and int(A[i]) <= N:
        cnt += 1
print(str(cnt))

Measured memory_bytes: 5212
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>fact(n+1,0);
    for(lint i=1;i<=n;i++){
        fact.at(i)=fact.at(i-1);
        for(lint j=i;j%2==0;j/=2){
            fact.at(i)++;
        }
    }
    std::string s;std::cin>>s;
    std::vector<lint>a(n);
    for(lint i=0;i<n;i++){
        a.at(i)=s.at(i)-'1';
    }

    // 1 のパリティが 1 なら 1
    lint cum=0;
    for(lint i=0;i<n;i++){
        if(fact.at(n-1)-fact.at(i)-fact.at(n-1-i))continue;
        cum^=a.at(i)==1;
    }
    if(cum){
        std::cout<<1<<'\n';
        return 0;
    }

    // 1 が存在したら 0
    if(std::find(a.begin(),a.end(),1)!=a.end()){
        std::cout<<0<<'\n';
        return 0;
    }

    // 2 のパリティが 1 なら 2
    cum=0;
    for(lint i=0;i<n;i++){
        if(fact.at(n-1)-fact.at(i)-fact.at(n-1-i))continue;
        cum^=a.at(i)==2;
    }
    if(cum){
        std::cout<<2<<'\n';
        return 0;
    }
    std::cout<<0<<'\n';
}


Measured memory_bytes: 17052
# ABC121C

import numpy as np

n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
a = np.array(a)
b = np.array(b)
c = np.argsort(a)
a = a[c]
b = b[c]
cost = 0
for i in range(len(a)):
    buy = min(b[i], m)
    cost += buy * a[i]
    # print(f"i = {i}  buy = {buy}  a[i] = {a[i]}")
    m -= buy
    if m == 0:
        break
print(cost)


Measured memory_bytes: 20668
#include <stdio.h>

long long abs_a(long long n){
    if (n>=0){
        return n;
    } else {
        return -1*n;
    }
}

int main (void){
    int N;
    scanf ("%d", &N);
    long long a[N];
    long long sum = 0;
    long long min = 0;
    for (int i=0; i<N; i++){
        scanf ("%lld", &a[i]);
        sum += a[i];
        min += abs_a (a[i]);
    }
    //FR
    long long x = 0;
    for (int i=0; i<N-1; i++){
        x += a[i];
        //printf ("min: %lld", min);

        if (abs_a (2*x-sum) < min){
            min = abs_a (2*x-sum);
            //printf ("poi:%lld\n", min);
        }
    }

    printf ("%lld\n", min);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll H,W,K;
	cin >> H >> W >> K;
	if(W==1){
		if(K==1)cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	vector<ll> bridge(W+2,0),nothing(W+2,0);
	FOR(i,0,1<<(W-1)){
		string s;
		FOR(j,0,W-1){
			if(i&(1<<j))s+='1';
			else s+= '0';
		}
		bool add = true;
		FOR(j,0,s.size()-1){
			if(s[j]=='1'&&s[j+1]=='1')add = false;
		}
		if(add){
			FOR(j,0,s.size()){
				if(s[j]=='1')bridge[j+1]++;
			}
			if(s[0]=='0')nothing[1]++;
			FOR(j,0,s.size()-1){
				if(s[j]=='0'&&s[j+1]=='0')nothing[j+2]++;
			}
			if(s[s.size()-1]=='0')nothing[W]++;
		}
	}
	//for(auto x:bridge)cout<<x<<endl;

	ll dp[H+1][W+2];
	FOR(i,0,H+1)FOR(k,0,W+2)dp[i][k]=0;
	dp[0][1] = 1;

	FOR(i,1,H+1){
		FOR(j,1,W+1){
			dp[i][j] += (dp[i-1][j-1]*bridge[j-1])%MOD + (dp[i-1][j]*nothing[j])%MOD + (dp[i-1][j+1]*bridge[j])%MOD;
			dp[i][j] %= MOD;
		}
	}
	/*FOR(i,0,H+1){
		FOR(j,1,W+1){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << dp[H][K] << endl;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	scanf("%d", &n);
	int t = ceil(n/1000.0);
	printf("%d", 1000*t - n); 
	return 0;
}

Measured memory_bytes: 3840
import math

N, M = map(int, input().split())
N, M = max(N,M), min(N,M)
MOD = 10**9+7

if N == M:
    ans = math.factorial(N) ** 2 * 2
elif N - M == 1:
    ans = math.factorial(M) ** 2 * N
else:
    ans = 0

print(ans % MOD)


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace
 
using namespace std;
using ll = long long;
using ii = pair<int, int>;
 
const int N = 410;
int n;
 
ll pd[N][N];
ll sum[N][N];
int a[N];
 
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", a+i);
		for (int j = i; j >= 1; j--)
			sum[j][i] = sum[j+1][i] + a[j];
	}
	
 
	for (int sz = 2; sz <= n; sz++)
	{
		for (int i = 1; i + sz - 1 <= n; i++)
		{
			int j = i + sz - 1;
			pd[i][j] = 1e18;
			for (int mid = i; mid < j; mid++)
			{
				//if (mid == i)
				//	pd[i][j] = min(pd[i][j], a[i] + sum[i+1][j] + pd[i+1][j]);
				//else
					pd[i][j] = min(pd[i][j], sum[i][mid] + sum[mid+1][j] + pd[i][mid] + pd[mid+1][j]);
			}
		}
	}
	printf("%lld\n", pd[1][n]);
	return 0;
}

Measured memory_bytes: 2816
A,B,C,X,Y = map(int,input().split())
p=5000000000
for i in list(range(0,max([X+1,Y+1]))):
    if p > max([X-i,0])*A+max([Y-i,0])*B+2*C*i:
        p=max([X-i,0])*A+max([Y-i,0])*B+2*C*i
print(p)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

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

signed main() {
  int N, M;
  cin >> N >> M;
  if (N % 2) {
    int m = 0;
    repp(i, 1, N / 2) {
      cout << i << ' ' << (N + 1 - i) << endl;
      m++;
      if (m == M)
        break;
    }
  } else {
    int m = 0;
    int mx = (N - 1) / 2;
    int l = 1, r = l + mx + 1;
    repr(d, (N - 1) / 2, 1) {
      if (m % 2 == 0) {
        cout << l << ' ' << (l + d) << endl;
        l++;
      } else {
        cout << r << ' ' << (r + d) << endl;
        r++;
      }
      m++;
      if (m == M)
        break;
    }
  }
}

Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
  
using namespace std;

int main() {
	int n, a, b, c, count = 0;
	cin >> n >> a >> b;
	REP1(i,n+1) {
		int t = i;
		c = 0;
		REP(j,5) {
			c += t%10;
			t /= 10;
		}
		if ( a <= c && c <= b ) {
			count += i;
		}
	}
	cout << count << endl;
	return 0;	
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int a, b;

    AtCoder(FastScanner sc) {
        a = sc.nextInt();
        b = sc.nextInt();
    }

    void solve(PrintWriter out) {
        int cnt = 0;
        outer:
        for (int i = 1; i <= 12; i++) {
            for (int j = 1; j <= 31; j++) {
                if (i == j) cnt++;
                if (i == a && j == b) break outer;
            }
        }
        out.println(cnt);
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
# -*- coding: utf-8 -*-

import math


def g(nx, ny, nz):
    return nx ** 2 + ny ** 2 + nz ** 2 + nx * ny + ny * nz + nz * nx


def solve(n):
    # min_z = max(1, int(math.sqrt(n) / 3))
    max_z = max(1, int(math.sqrt(n - 2) - 1) if n > 2 else 1)
    # max_x = max(1, int(math.sqrt(n / 3) + 1))
    
    counter = [0 for _ in range(n + 1)]
    
    for z in range(1, max_z + 1):
        for y in range(1, max_z + 1):
            for x in range(1, max_z + 1):
                gn = g(x, y, z)
                if gn <= n:
                    counter[gn] += 1
    
    for i in range(1, n + 1):
        print(counter[i])


N = int(input())

solve(N)



Measured memory_bytes: 9272
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n,k;cin>>n>>k;
  vector<ll> A,F;
  rep(i,n){
    ll a;cin>>a;
    A.push_back(a);
  }
  rep(i,n){
    ll f;cin>>f;
    F.push_back(f);
  }
  sort(all(A));
  sort(all(F));
  reverse(all(F));
  ll ok = 1e13;
  ll ng = -1;
  while(ok-ng >= 2){
    ll mid = (ok+ng)/2;
    ll count = 0;
    rep(i,n){
      count += max((ll)0, A[i] - mid / F[i]);
    }
    if(count <= k){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout<<ok<<endl;
  return 0;
}


Measured memory_bytes: 5360