akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   prime[0]=prime[1]=-1;
    for(int i=2;i<=10000000;i++){
        if(prime[i]!=-1){
            prime[i]=1;
            for(int j=i+i;j<=10000000;j+=i)prime[j]=-1;
        }
    }
    for(int i=3100;i<=10000000;i++){
        if(prime[i]==0){
            prime[i]=1;
        }
    }
    int n;
    while(cin>>n,n){
        while(n){
            if(n>7&&prime[n]==1
            &&prime[n-2]==1&&prime[n-6]==1
            &&prime[n-8]==1){
                cout<<n<<endl;
                break;
            }
            n--;
        }
        if(n==0) cout<<"0"<<endl;
    }
    return 0;
}


Measured memory_bytes: 44512
#include<iostream>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N,M;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	while(cin>>N>>M,N)
	{
		UF uf(N);
		int cnt=N;
		for(int i=0;i<M;i++)
		{
			int u,v;cin>>u>>v;
			u--,v--;
			if(uf.unite(u,v))cnt--;
		}
		long ans=power(2,cnt);
		if(M!=0)ans=(ans+1)%mod;
		cout<<ans<<endl;
	}
}



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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format

    int N, K;
    cin >> N >> K;

    vec<int> hoge(N);

    for(int i=0; i < K; i++){
        int d;
        cin >>  d;
        for(int j=0; j < d; j++){
            int a;
            cin >> a;
            a--;
            hoge.at(a) = 1;
        }
    }

    cout << N - accumulate(hoge.begin(), hoge.end(), 0) << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[200010];
    int ans=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        ans = ans ^ a[i];
    }
    
    for(int i=0; i<n-1; i++){
        ans = ans ^ a[i];
        cout << ans << " ";
        ans = ans ^ a[i];
    }
    ans = ans ^ a[n-1];
    cout << ans << endl;

    return 0;
}

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

typedef vector<int> vi;

int H, W, h, w;
vector<vi> A;

int main(void) {
	cin >> H >> W >> h >> w;
	if ((H % h == 0) && (W % w == 0)) {
		cout << "No\n";
		return 0;
	}
	vi v;
	v.resize(W, 0);
	A.resize(H, v);
	if (W % w != 0) {
		int n = W / w;
		int p, m;
		p = 1;
		while (true) {
			m = -p - 1;
			if ((n + 1) * p + n * m > 0)
				break;
			++p;
		}
		for (int i = 1; i <= n; ++i) {
			for (int j = 0; j < H; ++j) {
				A[j][w * (i - 1)] = p;
				A[j][w * (i - 1) + w - 1] = m;
			}
		}
		for (int j = 0; j < H; ++j)
			A[j][w * n] = p;
	}
	else {
		int n = H / h;
		int p, m;
		p = 1;
		while (true) {
			m = -p - 1;
			if ((n + 1) * p + n * m > 0)
				break;
			++p;
		}
		for (int j = 1; j <= n; ++j) {
			for (int i = 0; i < W; ++i) {
				A[h * (j - 1)][i] = p;
				A[h * (j - 1) + h - 1][i] = m;
			}
		}
		for (int i = 0; i < W; ++i)
			A[h * n][i] = p;
	}

	cout << "Yes\n";
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			cout << A[j][i];
			if (i == W - 1)
				cout << '\n';
			else
				cout << ' ';
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
int main()
{
    int n, x, L[100], d = 0,count = 1;
    scanf("%d%d", &n, &x);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &L[i]);
    }
    for (int i = 1; i < n+1; i++)
    {
        d = d + L[i - 1];
        if (d > x)
            break;
        count++;
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "string"
#include <stack>
using namespace std;
/*vector<string> split(const string &s, char d)
{
	vector<string> v;
	string str;

	for (char ch : s)
	{
		if (ch == d)
		{
			if (!str.empty())
			{
				v.push_back(str);
			}
		}
		else
		{
			str += ch;
		}

		if (!str.empty())
		{
			v.push_back(str);
		}

		return v;
	}
}*/
void A()
{
	stack<int> stack;
	string str;
	while(cin >> str)
	{
		if (str == "+" || str== "-" || str == "*")
		{
			int b = stack.top();
			stack.pop();
			int a = stack.top();
			stack.pop();
			int c;
			if (str == "+")
			{
				c = a + b;
			}
			else if (str == "-")
			{
				c = a - b;
			}
			else
			{
				c = a * b;
			}

			stack.push(c);
		}
		else
		{
			int num = stoi(str);
			stack.push(num);
		}
	}

	cout << stack.top() << endl;
}

void B()
{

}

void C()
{

}

void D()
{

}
int main()
{
	A();
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const long long mod = 1e9 + 7;
const long long MAX_P = 200010;
typedef long long ll;
long long qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
long long qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;

//素因数分解 O(√n)
map<int, int>prime_factor(int n) {
	map<int, int> res;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

class combination {
public:
	ll fact[MAX_P]; // n! mod pのテーブル(O(p))
	ll p;
	// factテーブルを初期化する
	combination(ll x) {  // x : 余り(1e9 + 7など)
		p = x;
		fact[0] = 1;
		for (ll i = 1; i < MAX_P; i++) {
			fact[i] = fact[i - 1] * i % p;
		}
	}
	//拡張ユークリッドの互除法
	ll extgcd(ll a, ll b, ll& x, ll& y) {
		ll d = a;
		if (b != 0) {
			d = extgcd(b, a%b, y, x);
			y -= (a / b) * x;
		}
		else {
			x = 1; y = 0;
		}
		return d;
	}
	//mod上の逆元
	ll mod_inverse(ll a, ll m) {
		ll x, y;
		extgcd(a, m, x, y); //extgcdが必要
		return (m + x % m) % m;
	}
	//n! = a p^eとしたときの a mod pを求める O(log_p a)
	ll mod_fact(ll n, ll p, ll& e) {
		e = 0;
		if (n == 0) return 1;

		//pの倍数の部分を計算
		ll res = mod_fact(n / p, p, e);
		e += n / p;

		//(p - 1)!≡-1なので、(p-1)!^(n/p)はn/pの偶奇だけで計算できる
		if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
		return res * fact[n % p] % p;
	}

	//mod p 上の二項係数
	ll mod_comb(ll n, ll k) {
		if (n < 0 || k < 0 || n < k) return 0;
		ll e1, e2, e3;
		ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
		if (e1 > e2 + e3) return 0;
		return a1 * mod_inverse(a2 * a3 % p, p) % p;
	}
};
int main() {
	ll n, m; cin >> n >> m;
	auto lyn = prime_factor(m);
	combination c(mod);
	ll ans = 1;
	for (auto i : lyn) {
		ans *= c.mod_comb(i.second + n - 1, i.second);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int c1 = 0, c2 = 0, c4 = 0;
	for(int i = 0; i < n; ++ i) {
		int x; cin >> x;
		if(x % 4 == 0) ++ c4;
		else if(x % 2 == 0) ++ c2;
		else ++ c1;
	}
	if(c4 < c1 - 1) cout << "No\n";
	else {
		if(c4 == c1 - 1 && c2) cout << "No\n";
		else cout << "Yes\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int A[100000];
bool f(int n){
    long long size=A[n];
    for(int i=N-1;i>=0;i--){
        if(i==n)continue;
        if(A[i]<=size*2)size+=A[i];
        else return false;
    }
    return true;
}
int main(){
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A,A+N,greater<int>());
    int ok=0,ng=N,mid;
    while(abs(ok-ng)>1LL)mid=(ok+ng)/2LL,(f(mid))?ok=mid:ng=mid;
    cout<<ok+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <22/Jun/2019 05:38:20 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n, l = get_ints()
    arr = [0] * n
    for i in range(n):
        arr[i] = l + i
    arr.sort()
    # print(arr)
    tmp = [(abs(arr[i]), i) for i in range(n)]
    tmp.sort()
    # print(tmp)
    ans = 0
    for i in range(1, n):
        ans += arr[tmp[i][1]]
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


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


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


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


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

int main(){

	int A=0,f=0,s=0;
	for(int i=0;i<3;i++){
		cin>>A;
		if(A%5==0) f++;
		else if (A%7==0) s++;
	}

	if(f==2&&s==1){
		cout<<"YES";
	}else{
		cout<<"NO";
	}

}



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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,x;cin>>n>>x&&n|x;){
		vi a(n);
		rep(i,n) cin>>a[i];

		ll res=0;
		if(a[0]>x){
			res+=a[0]-x;
			a[0]=x;
		}
		repi(i,1,n){
			ll cnt=max(a[i-1]+a[i]-x,0);
			res+=cnt;
			a[i]-=cnt;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 764
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    rep(i, n + 1){
        rep(j, m + 1){
            if(i * (m - j) + j * (n - i) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),M = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		for(int i=0;i< N;i++) {
			list.add(sc.nextInt());
		}
		double sum = list.stream().mapToInt(v->v).sum();
		ArrayList<Integer> sort = list.stream().sorted(Comparator.reverseOrder()).limit(M).collect(Collectors.toCollection(ArrayList::new));
		double limit =  sum/4/M;
		if(sort.get(M-1)<limit) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 28628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int i1 = Integer.parseInt(s.substring(0, 1));
		int i2 = Integer.parseInt(s.substring(1, 2));
		int i3 = Integer.parseInt(s.substring(2, 3));
		int i4 = Integer.parseInt(s.substring(3, 4));
		for(int i = 0; i < 2; i++) {
			for(int m = 0; m < 2; m++) {
				for(int j = 0; j < 2; j++) {
					int ans = i1;
					if(i == 0) {
						ans += i2;
					} else {
						ans -= i2;
					}
					if(m == 0) {
						ans += i3;
					} else {
						ans -= i3;
					}
					if(j == 0) {
						ans += i4;
					} else {
						ans -= i4;
					}

					if(ans == 7) {
						StringBuilder sb = new StringBuilder(String.valueOf(i1));
						if(i == 0) {
							sb.append("+");
						} else {
							sb.append("-");
						}
						sb.append(String.valueOf(i2));
						if(m == 0) {
							sb.append("+");
						} else {
							sb.append("-");
						}
						sb.append(String.valueOf(i3));
						if(j == 0) {
							sb.append("+");
						} else {
							sb.append("-");
						}
						sb.append(String.valueOf(i4));
						sb.append("=7");
						System.out.println(sb.toString());
						return;
					}
				}
			}
		}
	}
}

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

using namespace std;

struct kek{
    int a;
    int b;
};

int n,i,j;
kek t[200005];

bool cmp(kek a, kek b){
    if (a.b==b.b) return a.a<b.a; 
    return a.b<b.b;
}

int main() 
{
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>t[i].a>>t[i].b;
    }
    
    sort(t+1,t+n+1,cmp);
    
    //for (i=1; i<=n; i++) cout<<t[i].a<<" "<<t[i].b<<endl; return 0;
    
    int sm=0;
    for (i=1; i<=n; i++)
    {
        sm+=t[i].a;
        if (sm>t[i].b) return cout<<"No",0;
    }
    cout<<"Yes";
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];

    vector<ll> dp;
    dp.push_back(0);
    rep(i,N) dp.push_back(dp[dp.size()-1]+a[i]);

    ll ans = INF_LL;
    REP(i, 1, N)
    {
        //cout << abs( (dp[i]-dp[0]) - (dp[dp.size()-1]-dp[i]) ) << endl;
        chmin(ans, abs( (dp[i]-dp[0]) - (dp[dp.size()-1]-dp[i]) ));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
int main(){
string s;
  cin >> s;
    for(int j = 'a'; j <= 'z'; j++){
      int cnt = 0;
      for(int i = 0; i < s.size(); i++){
        if(s[i] == j)
        cnt++;
      }
      if(cnt == 0){
        char a = j;
        cout << char(j) << endl;
        return 0;
      }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a == b&&c == d) {
		cout << "yes" << endl;
	}else if (a == c && b == d) {
		cout << "yes" << endl;
	}else if (a == d && b == c) {
		cout << "yes" << endl;
	}
	else cout << "no" << endl;
	cin >> c;
}

Measured memory_bytes: 3088
def e_multiplication_4(MOD=10**9 + 7):
    from functools import reduce
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    sign = {-1: 0, 0: 0, 1: 0}  # A の各要素の符号
    for a in A:
        if a == 0:
            sign[0] += 1
            continue
        sign[a // abs(a)] += 1

    if sign[1] == 0 and K % 2 == 1:
        # どうやっても解は負。絶対値の小さなものから掛けていく
        A.sort(reverse=True)
        return reduce(lambda x, y: (x * y) % MOD, A[:K])
    if sign[1] == 0 and K % 2 == 0:
        # 先程と違って絶対値の大きなものから掛けても解は正になる
        A.sort()
        return reduce(lambda x, y: (x * y) % MOD, A[:K])

    A.sort()
    ans = 1
    i, j = 0, N - 1
    while K > 0:
        # 負の絶対値が大きいものから 2 個取るか？　正の絶対値が大きいものから 1 個取るか？
        # i, j がそれぞれ負の値、非負の値を指さなくなった場合、if 文のどちらかを
        # 確実に通らなくなるので、i, j についての条件は必要ない
        if K > 1 and A[i] * A[i + 1] >= A[j] * A[j - 1]:
            ans *= A[i] * A[i + 1]
            i += 2
            K -= 2
        else:
            ans *= A[j]
            j -= 1
            K -= 1
        ans %= MOD
    return ans

print(e_multiplication_4())

Measured memory_bytes: 32240
import math
def check(s):
  #print("check:{}".format(s))
  n = len(s)
  n2 = math.ceil(n/2)
#  if n == 1:
#    return False
  for i in range(0,n2):
    ni = n-i
    if s[i:i+1] != s[ni-1:ni]:
      return False
  return True

s = input('')
if check(s):
  # 1文字目～(N-1)/2文字目が回文か、判定 
  n2 = math.ceil((len(s)-1)/2)
  s2 = s[0:n2]
#  print("n:{} s:{}".format(n2,s2))
  if check(s2):
    # (N+3)/2 文字目までの回文判定
    n3 = math.ceil((len(s)+3)/2)
    s3 = s[n3-1:]
#    print("n:{} s:{}".format(n3,s3))
    if check(s3):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')


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

int main()
{
  int n;
  cin>>n;
  ll h[n+1],dp[n+1];
  for(int i=1;i<=n;i++)cin>>h[i];
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  for(int i=3;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll N;
ll A[250000], v[500][500];
ll dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
bool B[500][500];


int main() {
    init();
    cin >> N;
    rep(i, N * N) cin >> A[i], A[i]--;
    
    rep(i,N)rep(j,N){
        v[i][j] = min(min(i, j), min(N - i - 1, N - j - 1)), B[i][j] = true;
    }

    queue<pair<ll,ll>> q;
    ll ans = 0;

    rep(i,N*N){
        ll R = A[i] / N, C = A[i] % N;
        ans += v[R][C];
        B[R][C] = false;

        q.emplace(R, C);
        while(!q.empty()){
            ll r,c;
            tie(r, c) = q.front(), q.pop();
            ll cost = v[r][c] + B[r][c];

            rep(j, 4){
                ll rr = r + dx[j], cc = c + dy[j];
                if (rr < 0 or rr >= N or cc < 0 or cc >= N) continue;
                if (v[rr][cc] > cost) q.emplace(rr, cc), v[rr][cc] = cost;
            }

        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t;
	cin >> s;
	cin >> t;

	vector<char> alpha = { 'a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k','l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't','u', 'v', 'w', 'x', 'y', 'z' };
	vector<vector<int>> s_pos(26, vector<int>(0));
	vector<vector<int>> t_pos(26, vector<int>(0));

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < s.length(); j++) {
			if (alpha.at(i) == s.at(j)) {
				s_pos.at(i).push_back(j);
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < t.length(); j++) {
			if (alpha.at(i) == t.at(j)) {
				t_pos.at(i).push_back(j);
			}
		}
	}
	sort(s_pos.begin(), s_pos.end());
	sort(t_pos.begin(), t_pos.end());
	if (s_pos == t_pos) { 
		cout << "Yes"; }
	else { cout << "No"; }
}

Measured memory_bytes: 2564
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
static const ll MOD = 1000000007;

int main(){
	int n, k;
	cin >> n >> k;
	vector<vector<ll> > memo(k + 1, vector<ll>(n + 1, 0));
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= n; j++){
			if(i == 0 && j == 0) memo[i][j] = 1;
			else if(i == 0 || j == 0) continue;
			else{
				memo[i][j] = memo[i - 1][j - 1] + i * memo[i][j - 1];
				memo[i][j] %= MOD;
			}
		}
	}
	ll res = 0;
	for(int i = 0; i <= k; i++){
		res += memo[i][n];
		res %= MOD;
	}
	cout << res << endl;
	return 0;
}



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

string change(int a)
{
  stringstream ss;
  ss << a;
  return ss.str();
}

int main()
{
  string s;
  stack<string> st1;
  stack<string> st2;
  int res1 = 0;
  int res2 = 0;
  int ans;
  
  cin >> s;
  cin >> ans;
  
  for(int i = 0;i < s.size();i++){
    string str = &s[i];
    st1.push(str);
    if(i < 2) continue;
    
    if(s[i-1] == '+'){
      int a = atoi(st1.top().c_str());
      st1.pop();
      st1.pop();
      int b = atoi(st1.top().c_str());
      st1.pop();
      st1.push(change(a+b));
    }
    else if(s[i-1] == '*'){
      int a = atoi(st1.top().c_str());
      st1.pop();
      st1.pop();
      int b = atoi(st1.top().c_str());
      st1.pop();
      st1.push(change(a*b));
    }
    //cout << "***" << st1.top() << endl;
  }
  res1 = atoi(st1.top().c_str());
  st1.pop();
  
  for(int i = 0;i < s.size();i++){

    if(s[i] == '+') continue;

    string str = &s[i];
    st2.push(str);
    //cout << str << endl;
    if(i < 2) continue;
    
    if(s[i-1] == '*'){
      int a = atoi(st2.top().c_str());
      st2.pop();//a
      st2.pop();//*
      int b = atoi(st2.top().c_str());
      st2.pop();//b
      st2.push(change(a*b));
      //cout << "***" << st2.top() << endl;
    }
  }
  while(!st2.empty()){
    if(st2.top() == "+" || st2.top() == "*") st2.pop();
    else{
      res2 += atoi(st2.top().c_str());
      st2.pop();
      //cout << "res2 == " << res2 << endl;
      //if(!st2.empty()) cout << st2.top() << endl;
    }
  }
  //cout << res1 << endl << res2 << endl;
  
  if(res1 == ans && res2 == ans) cout << "U" << endl;
  else if(res2 == ans) cout << "M" << endl;
  else if(res1 == ans) cout << "L" << endl;
  else cout << "I" << endl;
  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> ac;
    for(int i = 1;i < n;i++) {
        if(s[i-1] == 'A' && s[i] == 'C') ac.push_back(i-1);
    }
    int sum[100001];
    auto itr = ac.begin();
    for(int i = 1;i <= n;i++) {
        sum[i] = sum[i-1];
        if(itr != ac.end() && *itr == i-1) {
            sum[i]++;
            itr++;
        }
    }
    for(int i = 0;i < q;i++) {
        int l,r;
        cin >> l >> r;
        cout << sum[r-1] - sum[l-1] << endl;
    }
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+5;
const ll mod =   1e9+7;
int n;
int arr[4];
int main()
{  fast cin>>n;
while(n--){
	string s;
	cin>>s;
	if(s=="AC")
	arr[0]++;
	else if(s=="WA")
	arr[1]++;
	else if(s=="TLE")
	arr[2]++;
	else
	arr[3]++;
}
cout<<"AC x "<<arr[0]<<endl;
cout<<"WA x "<<arr[1]<<endl;
cout<<"TLE x "<<arr[2]<<endl;
cout<<"RE x "<<arr[3]<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stack>
//#include <cctype>
#include <algorithm>
using namespace std;

int main(void){
    stack<int> s;
    int a,b;
    string n;
    while(cin>>n){
        if(isdigit(n[0]))
            s.push(atoi(n.c_str()));
        else{
            a=s.top();
            s.pop();
            b=s.top();
            s.pop();
            if(n[0]=='+')b+=a;
            else if(n[0]=='-')b-=a;
            else if(n[0]=='*')b*=a;
            s.push(b);
        }
    }
    cout<<s.top()<<endl;
}

Measured memory_bytes: 3208
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char str[1100][1100];
char wolf[6]="RGBY";

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c%2){
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)str[i][j]=wolf[(i+j)%2];
	}else{
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				int X=(i+j);
				int Y=(i-j)+10000;
				int cl=0;
				if(X/2/(c/2)%2)cl++;
				if(Y/2/(c/2)%2)cl+=2;
				str[i][j]=wolf[cl];
			}
		}
	}
	for(int i=0;i<a;i++)printf("%s\n",str[i]);
}

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

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; ++i) cin >> x[i];
	int ans = 1e9;
	for (int i = 0; i < n - k + 1; ++i) {
		int t = x[i + k - 1] - x[i];
		ans = min(ans, abs(x[i]) + t);
		ans = min(ans, abs(x[i + k - 1]) + t);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#define N 4010
using namespace std;
using lli = long long int;
lli dp[N][N], sum[N + 1];
int opt_pos[N][N];

int main(){
  int n;
  std::cin >> n;
  vector<lli> w(n);
  for (int i = 0; i < n; i++) std::cin >> w[i];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) dp[i][j] = 1e15;
    dp[i][i] = sum[i] = 0;
    opt_pos[i][i] = i;
  }
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = w[i - 1] + sum[i - 1];
  }
  // for (int i = 0; i <= n; i++) {
  //   std::cout << sum[i] << " ";
  // }
  // std::cout << std::endl;
  for (int i = 2; i <= n; i++) {//長さ
    for (int j = 0; i + j <= n; j++) { // 始点
      lli tail = i + j - 1;
      for (int k = opt_pos[j][tail - 1]; k <= opt_pos[j + 1][tail]; k++) {// 分割位置
        if(dp[j][tail] >= dp[j][k - 1] + dp[k][tail] + sum[tail + 1] - sum[j]){
          dp[j][tail] = dp[j][k - 1] + dp[k][tail] + sum[tail + 1] - sum[j];
          opt_pos[j][tail] = k;
        }
      }
    }
  }

  
  std::cout << dp[0][n - 1] << std::endl;
  return 0;
}




Measured memory_bytes: 173712
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e14;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)


using namespace std;

int main(){
    ll N,K;
    cin >> N >> K;
    ll ans=K;
    llrep(i,N-1) ans *= (K-1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

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

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n,k;
	cin>>n>>k;

	vector<int>a(n);

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

	sort(rall(a));
	int sum=0;

	for(i=k;i<n;i++)
	{
		sum+=a[i];
	}

	cout<<sum<<endl;

}

Measured memory_bytes: 4788
# 2 5 1 7 3
# 4 2 2 5
#   2 
# 1 4 1 
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
kuriage = 0
total = 0
for i in range(n+1):
        # print(str(i)+'ばんめ')
        # if a[i] <= b[i]:
        #         print('if'+str(1))
        #         kuriage = b[i] - a[i]
        #         # b[i] = b[i]+kuriage
        #         total += a[i]
        #         print(kuriage)
        #         print(total)
        if kuriage+b[i] >= a[i]:
                # print('if1')
                if a[i] >= kuriage:
                        res = a[i] - kuriage
                else:
                        res = 0
                kuriage = b[i] - res
                # b[i] = b[i]+kuriage
                total += a[i]
                # print(kuriage)
        elif kuriage+b[i] < a[i]:
                # print('if2')
                # total += a[i] - (kuriage+b[i])
                total += kuriage+b[i]
                kuriage = 0
                # print(kuriage)
print(total)

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

vector<int> vec;

int main() {
	int Tot, sta; cin >> Tot >> sta; vec.push_back(sta);
	for (int pos = 1, tmp; pos <= Tot; pos++) {
		cin >> tmp, vec.push_back(tmp);
	}
	sort(vec.begin(), vec.end());
	int Lim = INT_MAX, ans = 1;
	for (int pos = 1; pos < vec.size(); pos++)
		Lim = min(Lim, vec[pos] - vec[pos - 1]);

	for (int step = Lim; step >= 2; step--) {
		int pos;
		for (pos = 1; pos < vec.size(); pos++) {
			if ((vec[pos] - vec[pos - 1]) % step != 0)
				break;
		}
		if (pos == vec.size()) {
			ans = step; break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
def prime_factorizarion(n):
	arr = []
	temp = n
	for i in range(2, int(n**0.5)+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp//=i
			arr.append([i,cnt])
	
	if temp!=1:
		arr.append([temp,1])
	
	if arr==[]:
		arr.append([n,1])
	
	return arr

N=int(input())
if N==1:
    print(0)
    exit()
primes=prime_factorizarion(N)

ans=0
for prime,count in primes:
    cnt=1
    tmp=1
    while True:
        if tmp>count:
            break
        ans+=1
        cnt+=1
        tmp+=cnt
print(ans)

Measured memory_bytes: 9488
#include <bits/stdc++.h>
#define pb push_back
#define INF 1<<30
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL  ({ll  a; scanf("%lld", &a); a;})
#define EPS 1e-10
#define pi acos(0.0)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<int> vi ;
typedef vector<ll>vl;

#define FOR(i,n) for( __typeof(n)i = 0 ; i < n ; i++)
#define FORL(i,a, b) for( __typeof(n)i = a ; i <= b ; i++)
#define FORR(i,a, b) for( __typeof(n)i = a ; i >= b ; i--)
#define For(i,n) for( __typeof(n)i = 1 ; i <= n ; i++)
#define forstl(i,n) for(__typeof(n.begin())i = n.begin();i!=n.end();i++)
#define forab(i,a,b) for( __typeof(b) i = a ; i <= (b) ; i++ )
#define forba(i,b,a) for( __typeof(b) i = b ; i >= (a) ; i-- )

int x[4] = {0 , 0 , -1, 1};
int y[4] = {1, -1, 0  , 0};



void solve()
{
	ll n;
	cin >> n;

	ll l[n];
	FOR(i , n)
	cin >> l[i];

	ll ans = 0;
	FOR(i , n)
	{
		FORL(j , i + 1 , n - 1)
		{
			FORL(k , j + 1 , n - 1)
			{
				if (l[i] != l[j] && l[k] != l[i] && l[j] != l[k])
				{
					if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[i] + l[k] > l[j])
					{	ans++; }
				}
			}
		}
	}
	cout << ans << endl;
}

int main()
{


	int T = 1;
	//cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)

	//freopen("input.txt", "r", stdin);

	// Printing the Output to output.txt file
	//freopen("output.txt", "w", stdout);

	while (T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
string s;
LL dp[500011];
vector<int>v;

int main(){
    REP(i,500001){
        dp[i]=0;
    }
    cin>>N;
    cin>>s;
    LL ans=0;
    v.push_back(0);
    REP(i,s.size()){
        if(s[i]=='0'){
           v.push_back(i+1);
        }
    }
    v.push_back(N+1);
    
    int i=1;
    REP(j,N+1){
        if(j==0)continue;
        if(j==N)continue;
        dp[j]=max(dp[j-1],dp[j]);
        if(j==v[i]){
    //cout<<"v"<<v[i]<<endl;

        int x=v[i];
        int p=v[i-1];
        int nx=v[i+1];
        dp[x]=max(dp[p],dp[x-1]);//取らない
       // cout<<"dp"<<dp[x]<<endl;
        if(v[i+1]!=x+1&&v[i-1]!=x-1){
           dp[x+1]=max(dp[x],
                       max(dp[x-1],
                           max(dp[p]+(x-p-1),
                              max(dp[p+1]+(x-p-2),dp[x-2]+1)
                           )));
           if(nx-x>2){
              dp[nx-2]=max(dp[x+1],dp[x-2]+(nx-x-2));
           }
           dp[nx-1]=max(dp[x+1],max(dp[nx-2],dp[x-2]+(nx-x-1)));
        }
           i++;
        }
    }
    
    REP(i,N+1){
        //cout<<dp[i]<<endl;
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 6908
#include <bits/stdc++.h>
 
using namespace std;
const int N = 4e5 + 5;
typedef long long ll;
const ll inf=1e15;
#define pb push_back
const int INF=(0x3f3f3f3f);
 
//#define _

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
#ifdef _
  //freopen("text.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  const clock_t begin_time=clock();
#endif  
  
  
  int H,W,N;
  cin>>H>>W>>N;
  int mx=max(H,W);
  cout<<ceil((long double)N/mx)<<'\n';
  
  
#ifdef _
  //cout<<"\n\n\n\n\n\n\n\n\n\n\n";
  //cout<<float(clock()-begin_time)/CLOCKS_PER_SEC;
  cout<<fixed<<setprecision(45)<<double(clock()-begin_time)/CLOCKS_PER_SEC;
#endif
}










Measured memory_bytes: 384
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
import java.util.Stack;

class Graph {
	private int totalVertex;
	private int totalEdge;
	private LinkedList<LinkedList<Integer>> adjList;
	private boolean[] visited;
	private int[] inDegree;
	Stack<Integer> myStack = new Stack<Integer>(); 
	
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		totalEdge = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		inDegree = new int[totalVertex];
		visited = new boolean[totalVertex]; // default value is false
		
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			adjList.add(tmp);
		}
		
		for (int i = 0; i< totalEdge; i++) {
			int source = in.nextInt();
			int target = in.nextInt();
			adjList.get(source).add(target);
			inDegree[target] += 1;
		}
		in.close();
	}
	
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		LinkedList<Integer> tempNode;
		Iterator<LinkedList<Integer>> outer = adjList.iterator();
		int  rw = 0;
		while (outer.hasNext()) {
			tempNode = outer.next();
			Iterator<Integer> inner = tempNode.iterator();
			while(inner.hasNext()) {
				adjMatrix[rw][inner.next()] = 1;
			}
			rw++;
		}
			
		for(int i = 0; i<totalVertex;i++) {
			for (int j = 0; j < totalVertex; j++) {
				if (adjMatrix[i][j] != null) {
					System.out.print(adjMatrix[i][j]);
				} else {
					System.out.print(0);
				}
				if (j != totalVertex-1) {
					System.out.print(" ");					
				}				
			}
			System.out.println(); 
		}
	}
	
	public LinkedList<Integer> initialNode() {
		LinkedList<Integer> initialNode = new LinkedList<Integer>();
		// get a node with inDegree = 0
		for (int i = 0; i < totalVertex; i++) {
			if (inDegree[i] == 0) {
				initialNode.add(i);
			}
		}
		return initialNode;
	}
	
	public void DFS(int row) {
		visited[row] = true;
		LinkedList<Integer> neighbors = adjList.get(row);
		for(int i = 0; i < neighbors.size(); i ++) {
			int v1 = neighbors.get(i);
			if(visited[v1] == false) {
				DFS(v1);
			}
		}
		myStack.add(row);
	}
	public int getVertex() {
		return totalVertex;
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		// g.printAdjMatrix();
		// System.out.println();
		
		LinkedList<Integer>  myInitial = g.initialNode();
		for (int i = 0; i < myInitial.size(); i++) {
			g.DFS(myInitial.get(i)); // check every inDegree = 0 node
		}
		
		while(!g.myStack.empty()) {
			System.out.println(g.myStack.pop());
		}
	}
}


Measured memory_bytes: 72672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n;
    cin >> n;
    int ans = (n / 500) * 1000;
    n %= 500;
    ans += (n / 5) * 5;
    cnl(ans);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3620
n, m = map(int, input().split())

l = []

for i in range(n):
  l.append(list(map(int, input().split())))
           
l.sort(key=lambda x: x[0])

d = 0
cost = 0

for i in range(n):
  d += l[i][1]
  cost += l[i][0]*l[i][1]
  if d >= m:
    print(cost-l[i][0]*(d-m))
    exit()


Measured memory_bytes: 29024
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B;
  cin >> A >> B;

  cout << A * B << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int a, b;
  cin >> a >> b;
  int c = gcd(a, b);
  int ans = 0;
  for(int i = 2; i * i <= c; i++) {
    if(c % i == 0) ans++;
    while(c % i == 0) c /= i;
  }
  if(c != 1) ans++;
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define inf 0x3f3f3f3f
int dp[70000000];
char s[250000];
int f[250000];
int min(int a,int b){
	if (a>b) return b;else return a;
}
int main(){
	int n,i,x,ans,j;
	scanf("%s",s+1);
	s[0]='.';
	n=strlen(s)-1;
	memset(dp,inf,sizeof(dp));
	dp[0]=0;
	x=0;
	for (i=1;i<=n;i++) {
		x=x^(1<<(s[i]-'a'));
		ans=inf;
		for (j=1;j<=26;j++) 	ans=min(ans,dp[x^(1<<(j-1))]+1);
		dp[x]=min(dp[x],ans);
		f[i]=min(dp[x]+1,ans);
		
	}
	printf("%d\n",f[n]);
} 

Measured memory_bytes: 274560
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

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

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

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

    vector<string> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];

    for(int i = 0; i + m <= n; i++){
        for(int j = 0; j + m <= n; j++){

            bool tmp = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(a[i + k][j + l] != b[k][l]) tmp = false;
                }
            }

            if(tmp){
                cout << "Yes\n";
                return 0;
            }
        }
    }

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#define $;for(i=j=0;j<n?:(j=0,++i<n);j++)
#define _(a,b)$ for(b=l=0;l<n;)b+=a[i][l]*p[l++][j]%m $ a[i][j]=b%m;
long m=1e9+7,p[50][50],a[50][50],b[50][50],k;i,j,l;main(n){scanf("%d%ld",&n,&k)$ a[i][i]=scanf("%d",p[i]+j);for(;k;k/=2){if(k&1){_(a,b[i][j])}_(p,b[i][j])}$ k+=a[i][j];printf("%d",k%m);}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

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

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            int z = sc.nextInt();
            Queue<Integer> reds = new PriorityQueue<>();
            Queue<Integer> greens = new PriorityQueue<>();
            Queue<Integer> colorless = new PriorityQueue<>(Collections.reverseOrder());
            for (int i = 0; i < x; ++i) reds.offer(sc.nextInt());
            for (int i = 0; i < y; ++i) greens.offer(sc.nextInt());
            for (int i = 0; i < z; ++i) colorless.offer(sc.nextInt());
            while (reds.size() > n) reds.poll();
            while (greens.size() > m) greens.poll();
            while (reds.size() < n && !colorless.isEmpty()) reds.offer(colorless.poll());
            while (greens.size() < m && !colorless.isEmpty()) greens.offer(colorless.poll());
            while (colorless.size() > 0 && Math.min(reds.peek(), greens.peek()) < colorless.peek()) {
                if (reds.peek() < greens.peek()) {
                    reds.poll();
                    reds.offer(colorless.poll());
                }
                else {
                    greens.poll();
                    greens.offer(colorless.poll());
                }
            }
            long sum = 0;
            for (int i : reds) {
                sum += i;
            }
            for (int i : greens) {
                sum += i;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 100292
#include<stdio.h>

int main(void){
int x,y,a;
do {
scanf("%d%d",&x,&y);
if((x!=0) || (y!=0)){
if(x>y){
a=x;
x=y;
y=a;
}
printf("%d %d\n",x,y);
}

} while(x!=0 || y!=0);
return 0;
}

Measured memory_bytes: 600