akhauriyash/Code-Regression huggingface dataset:
/*---> 26 January 2020 <--- > 17:40:09 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
int32_t main(){__
	// int cur=1;
	int h;
	cin>>h;
	int val=log2(h);
	cout<<(1LL<<(val+1))-1<<"\n";
	// cout<<solve(h,1)<<"\n";
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  double s = (double)w*h/2.0;
  int m = 0;
  if ((2*x == w) && (2*y == h)){
    m = 1;
  }
  cout << s << " " << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
double sq(double d){
    return d*d;
}
double ave(int a, int n){
    return double(a)/double(n);
}
double pi = acos(-1);
int main(){
    int n;
    cin >> n;
    while (n != 0){
        double vari = 0;
        vector<double> d(n);
        int sum=0;
        rep(i, n){
            cin >> d[i];
            sum += d[i];
        }
        double ave = double(sum)/double(n);
        rep(i, n){
            vari += (d[i] - ave) * (d[i]-ave);
        }
        vari = vari/double(n);
      	double ans = sqrt(vari);
        printf("%.7f\n", ans);
        cin >> n;
    }
}


Measured memory_bytes: 3200
var
	n,i,j,k,t:Longint;
	s:int64;
	dp:array[0..100,0..63]of int64;
begin
	read(n);
dp[0,63]:=1;
for i:=1 to n do begin
for j:=0 to 63 do begin
for k:=0 to 3 do begin
t:=j*4+k;
if(t mod 64<>9)and(t mod 64<>33)and(t mod 64<>6)and(t<>25)and(t<>41)and(t<>57)and(t<>37)and(t<>45)then
dp[i,t mod 64]:=(dp[i,t mod 64]+dp[i-1,j])mod 1000000007;
end;end;end;
for i:=0 to 63 do s:=(s+dp[n,i])mod 1000000007;
writeln(s);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
// 	///*
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// 	freopen("error.txt", "w", stderr);
// #endif
//*/
	ll n;
	cin >> n;
	ll ans = 1e18;
	for (ll x = 1; x * x <= n; x++) {
		if (n % x == 0) {
			ans = min(ans, (x - 1) + (n / x - 1));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; ++i) {
        cin >> c[i];
    }
    for (int i = 0; i < h; ++i) {
        cout << c[i] << "\n";
        cout << c[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy";
    else if(s=="Rainy")cout<<"Sunny";
    else cout<<"Rainy";
    return 0;
}

Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

require 'pp'
K, N = attrs[0].map{|a| a.to_i}
A = attrs[1].map{|a| a.to_i}.sort
max = -1
start = -1
finish = -1
A.each_with_index do |a, i|
  if i == 0 then
    dif = a - (A[-1]-K)
  else
    dif = a - A[i-1]
  end
  if max < dif then
    max = dif
    start = i-1
    finish = i
  end
end
max = K-max if start < finish
puts max

Measured memory_bytes: 20344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	}
}

Measured memory_bytes: 17284
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No");
}
	

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const long long mod=1000000007;
long long n,inv[10050],mul[10050];
long long dp[4500][4500],a[200005],b[200005];
long long qpow(long long x,long long p)
{
	long long ret=1;
	while (p)
	{
		if (p%2) ret=ret*x%mod;
		x=x*x%mod;
		p/=2;
	}
	return ret;
}
long long C(long long n,long long m){return mul[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	mul[0]=1;
	for (long long i=1;i<=10000;i++) mul[i]=mul[i-1]*i%mod;
	inv[10000]=qpow(mul[10000],mod-2);
	for (long long i=9999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	while (~scanf("%lld",&n))
	{
		memset(dp,0,sizeof(dp));
		long long minus=0;
		for (long long i=1;i<=n;i++) scanf("%lld%lld",a+i,b+i),dp[-a[i]+2001][-b[i]+2001]++,minus=(minus+C(a[i]*2+b[i]*2,a[i]*2))%mod;
		for (long long i=-2000;i<=2001;i++) for (long long j=-2000;j<=2001;j++) i+=2001,j+=2001,dp[i][j]=((dp[i][j]+dp[i-1][j])%mod+dp[i][j-1])%mod,i-=2001,j-=2001;
		long long ans=0;
		for (long long i=1;i<=n;i++) ans=(ans+dp[a[i]+2001][b[i]+2001])%mod;
//		printf("%lld\n",minus);
		ans=((ans-minus)%mod*inv[2])%mod;
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 161664
# -*- coding: utf-8 -*-
from itertools import product

def rectangle_in_histgram(H):

    def calc(i, h):
        tmp_max = 0
        while stack[-1][1] > h:
            pi, ph = stack.pop()
            tmp_max = max(tmp_max, (i-pi)*ph)
            if len(stack) == 0:
                break

        if len(stack) == 0:
            stack.append([pi, h])
        elif stack[-1][1] < h:
            stack.append([pi, h])
        return tmp_max
    
    stack = [] # loc, height
    S_max = 0
    
    for i, h in enumerate(H):
        if len(stack) == 0:
            stack.append([i, h])
        elif h > stack[-1][1]:
            stack.append([i, h])
        elif h == stack[-1][1]:
            pass
        else:
            tmp_max = calc(i, h)
            S_max = max(S_max, tmp_max)

    tmp_max = calc(i+1, 0)
    S_max = max(S_max, tmp_max)
    return S_max


H, W = tuple(map(int, input().split()))
C = [tuple(map(int, input().split())) for _ in range(H)]
A = [[1]*W for _ in range(H)]
for h, w in product(range(H), range(W)):
    if C[h][w] == 1:
        A[h][w] = 0

for h, w in product(range(1, H), range(W)):
    if C[h][w] == 0:
        A[h][w] = A[h-1][w] + 1

result = 0
for a in A:
    result = max(result, rectangle_in_histgram(a))

print(result)

Measured memory_bytes: 65496
n, m = map(int, input().split())
A = [[0 for j in range(m)] for i in range(n)]

for i in range(n):
   A[i] = list(map(int, input().split()))

S = [0 for j in range(m)]
c = 0
for i in range(n):
   for j in range(m):
      print(A[i][j], end = "")
      print(" ", end = "")
   print(sum(A[i]))
   c += sum(A[i])

for j in range(m):
   sum = 0
   for i in range(n):
      sum += A[i][j]
   print(sum, end = "")
   print(" ", end = "")
print(c)


Measured memory_bytes: 6740
arr = input().split()
h=int(arr[0])
w=int(arr[1])
 
if w*h%2!=0 and h!=1 and w!=1:
    ans=(w*h+1)//2
elif h==1 or w==1:
    ans=1
else:
    ans=w*h//2
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int main() {
	vector<string> A(3);
	cin >> A[0] >> A[1] >> A[2];
	sort(A.begin(), A.end());
	//前処理
	vector<vector<bool>> data(6, vector<bool>(6000, true));
	vector<int>X = { 0,0,1,1,2,2 };
	vector<int>Y = { 1,2,0,2,0,1 };
	for (int z = 0; z < 6; ++z) {
		for (int i = 0; i < A[X[z]].size(); ++i) {
			bool b = true;
			for (int j = 0; j < A[Y[z]].size(); ++j) {
				if ((i + j) >= A[X[z]].size()) {
					continue;
				}
				if ('?' == A[Y[z]][j]) {
					continue;
				}
				if ('?' == A[X[z]][i + j]) {
					continue;
				}
				if (A[X[z]][i + j] != A[Y[z]][j]) {
					b = false;
				}
			}
			data[z][i] = b;
		}
	}
	map<pair<int, int>, int>p;
	for (int i = 0; i < 6; ++i) {
		pair<int, int>pp = make_pair(X[i], Y[i]);
		p[pp] = i;
	}
	int ans = 1e9;
	vector<int> v;
	for (int n = 0; n < 3; ++n) {
		v.push_back(n);
	}
	do {
		string a, b, c;
		a = A[v[0]];
		b = A[v[1]];
		c = A[v[2]];
		for (int i = 0; i <= a.size(); ++i) {
			for (int j = 0; j <= max(a.size() - i, b.size()); ++j) {
				//a 0....a.size()-1;
				//b i....b.size()-1+i;
				//c k    c.size()-1+k
				int k = i + j;
				int size = max(a.size(), max(b.size() + i, c.size() + k));
				bool b = true;
				if (!data[p[{v[0], v[1]}]][i]) {
					b = false;
				}
				if (!data[p[{v[0], v[2]}]][k]) {
					b = false;
				}
				if (!data[p[{v[1], v[2]}]][k - i]) {
					b = false;
				}
				if (b) {
					ans = min(ans, size);
				}
			}
		}
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
import heapq
n,m = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
ais.sort()
heap = []
for _ in range(m):
	u,v = map(int,raw_input().split(' ')) 
	heapq.heappush(heap, (-v,u))
res = 0
for j in range(n):
	
	if heap and -heap[0][0] > ais[j]:
		u,v = heapq.heappop(heap)
		v-=1
		res += -u
		if v >= 1: heapq.heappush(heap, (u,v))
	else:
		res += ais[j]
print res

Measured memory_bytes: 48968
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

int main(){
    string s;
    cin >> s;
    if(s == "SUN")cout << 7;
    else if(s == "MON")cout << 6;
    else if(s == "TUE")cout << 5;
    else if(s == "WED")cout << 4;
    else if(s == "THU")cout << 3;
    else if(s == "FRI")cout << 2;
    else cout << 1;
}

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

int main() {
    int s[14];
    int h[14];
    int c[14];
    int d[14];
    int n,m;
    char cr;
    for (int i=1;i<= 13;i++)
        s[i]=0;
    for (int i=1;i<= 13;i++)
        h[i]=0;
    for (int i=1;i<= 13;i++)
        c[i]=0;
    for (int i=1;i<= 13;i++)
        d[i]=0;
    cin >> n;
    for (int i =1;i<= n;i++){
        cin >> cr >> m;
        switch(cr){
            case 'S':s[m]=1;
                     break;
            case 'H':h[m]=1;
                     break;
            case 'C':c[m]=1;
                     break;
            case 'D':d[m]=1;
                     break;
        }
    }
    for (int i=1;i<= 13;i++)
        if (s[i]==0)
            cout << 'S' << ' ' << i << endl;
    for (int i=1;i<= 13;i++)
        if (h[i]==0)
            cout << 'H' << ' ' << i << endl;
    for (int i=1;i<= 13;i++)
        if (c[i]==0)
            cout << 'C' << ' ' << i << endl;
    for (int i=1;i<= 13;i++)
        if (d[i]==0)
            cout << 'D' << ' ' << i << endl;
}


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

int main() {

	string S;
	cin>>S;
	string sun="Sunny";
	string cloud="Cloudy";
	string rain="Rainy";
    if(S==sun)
    cout<<cloud<<endl;
    else if(S==cloud)
    cout<<rain<<endl;
    else
    cout<<sun<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, T = map(int,input().split())
A = []
B = []

for i in range(N):
	c, t = map(int,input().split())
	if t<=T:
		A.append(t)
		B.append(c)

if A == []:
	print("TLE")
else:
	print(min(B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, X;
    cin >> N >> X;
    int l,c=1,s=0;
    for ( int i = 0; i < N; i++ ) {
        cin >> l;
        s += l;
        if ( s <= X ) c++;
    }
    
    cout << c << '\n';
    return 0;
}

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

public class Main {

	public static final int mod = 1000000007;

	public static int count(int k) { // count number of ones in binary
		int c = 0;
		while (k > 0) {
			k &= k - 1;
			c++;
		}
		return c;
	}

	public static String pad(String s, int n) {
		for (int i = s.length(); i < n; i++) {
			s = "0" + s;
		}
		return s;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s;
		boolean[][] matches = new boolean[n][n];
		for (int i = 0; i < n; i++) {
			s = br.readLine().split(" ");
			for (int j = 0; j < n; j++)
				matches[i][j] = Integer.parseInt(s[j]) == 1;
		}

		int[][] dp = new int[n][(1 << n)];

		for (int i = 0; i < n; i++)
			dp[0][(1 << i)] = matches[i][0] ? 1 : 0; //last man left
	
		// i is women left, j is women bitmask
		
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < (1 << n); j++) {
				if (count(j) != i)
					continue;
				for (int k = 0; k < n; k++) { //for every possible man
					if (matches[k][i]) { //if the man and woman are compatible
						if (((1<<k) & j) == 0) { //and if the woman has not been taken in this bitmask
							dp[i][j^(1<<k)] += dp[i-1][j]; //the case where this woman is taken + current ways
							dp[i][j^(1<<k)] %= mod;
						}
					}				
				}
			}
		}
		
//		for (int i = 0; i <n; i++) {
//
//			for (int j = 0; j < (1 << n); j++) {
//				System.out.print(dp[i][j] + " ");
//			}System.out.println();
//		}
//		
		int ans = 0;
		for (int i = 0 ; i < (1<<n); i++)
			ans = ans + dp[n-1][i] % mod;
		System.out.println(ans);

	}

}


Measured memory_bytes: 240688
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    for (int i = 1; i <= 5; ++i) {
        ll x;
        cin >> x;
        if (x == 0) {
            cout << i << en;
            return;
        }
    }
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


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

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

    double h,w,n;
    cin >> h >> w >> n;

    cout << ceil(n / max(h,w)) << endl;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

class ModTools:
    """ 階乗・逆元用のテーブルを構築する """

    def __init__(self, MAX, MOD):

        # nCrならn、nHrならn+rまで作る
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, -1, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse

    def nCr(self, n, r):
        """ 組み合わせ """

        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

K = INT()
S = input()
N = len(S)

mt = ModTools(2*10**6, MOD)
ans = 0
for x in range(0, K+1):
    ans += mt.nCr(N+K-x-1, N-1) * pow(25, K-x, MOD) * pow(26, x, MOD) % MOD
ans %= MOD
print(ans)


Measured memory_bytes: 123236
a=[]
for i in range(51):
    a+=[i]*(i+1)

def prime_factor(n):
    ass=[]
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            ass.append(i)
            n=n//i
    if n!=1:
        ass.append(n)
    return ass
    
from collections import Counter
c=Counter(prime_factor(int(input())))
ans=0
for i in c.values():
    ans+=a[i]
print(ans)

Measured memory_bytes: 66272
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out,false);
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		int cut = -1;
		
		int[] ropes = new int[n];
		for(int i=0; i<n; i++) ropes[i] = sc.nextInt();
		
		for(int i=0; i<n-1; i++) {
			if(ropes[i]+ropes[i+1]>=l) {
				cut = i + 1;
				break;
			}
		}
		if(cut==-1) out.println("Impossible");
		else {
			out.println("Possible");
			for(int i=1; i<cut; i++) out.println(i);
			for(int i=n-1; i>cut; i--) out.println(i);
			out.println(cut); 
		}
		out.flush();
		out.close();
	}
}

Measured memory_bytes: 23012
#include <stdio.h>
#include <stdlib.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MIN(a,b) (((a)<(b))?(a):(b))
#define INF 100000000

typedef struct{
	int x;
	int y;
}Pos;
typedef struct{
	int front;
	int rear;
	int size;
	Pos *data;
}Queue;
void init_queue(Queue *q,int s){
	q->data=calloc(s,sizeof(Pos));
	q->front=q->rear=0;
	q->size=s;
	return;
}
void end(Queue *q){
	free(q->data);
	return;
}
void push(Queue *q,int s,int t){
	q->data[q->rear].x=s,q->data[q->rear].y=t;
	q->rear=(q->rear+1)%q->size;
}
Pos pop(Queue *q){
	Pos res=q->data[q->front];
	q->front=(q->front+1)%q->size;
	return res;
}
int isempty(Queue *q){
	return q->front==q->rear;
}
char map[810][810];
int d[810][810];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int sx,sy;
void read(int w,int h,char c){
	int i,j;
	scanf("%*c");
	FOR(i,0,h+2) map[0][i]=c,map[w+1][i]=c;
	FOR(i,0,w+2) map[i][0]=c,map[i][h+1]=c;
	FOR(i,1,h+1){
		FOR(j,1,w+1){
	        scanf("%c",&map[j][i]);
	        if(map[j][i]=='S') sx=j,sy=i,map[j][i]='.';
	    }
        scanf("%*c");
    }
    return; 
}
int main(void){
	int h,w,k,nx,ny,ans=INF,t,i,j;
	Queue que;
	Pos p;
	scanf("%d%d%d",&h,&w,&k);
	FOR(i,1,h+1){
		FOR(j,1,w+1){
			d[j][i]=INF;
		}
	}
	read(w,h,'#');
	init_queue(&que,h*w);
	push(&que,sx,sy);
	d[sx][sy]=0;
	while(!isempty(&que)){
		p=pop(&que);
		FOR(j,0,4){
			nx=p.x+dx[j],ny=p.y+dy[j];
			if(d[nx][ny]==INF&&map[nx][ny]!='#'){
				d[nx][ny]=d[p.x][p.y]+1;
				push(&que,nx,ny);
			}
		}
	}
	FOR(i,1,h+1){
		FOR(j,1,w+1){
			if(d[j][i]>k) continue;
			if(i==1||j==1||i==h||j==w){
				puts("1");
				return 0;
			}
			t=MIN(MIN(i-1,j-1),MIN(h-i,w-j));
			t=(t+k-1)/k+1;
			ans=MIN(ans,t);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8320
def solve():
    s = raw_input()
    n = len(s)
    ans = 0
    i, j = 0, n - 1
    while i < j:
        if s[i] != s[j]:
            if s[i] == 'x':
                ans += 1
                i += 1
            elif s[j] == 'x':
                ans += 1
                j -= 1
            else:
                return -1
        else:
            i += 1
            j -= 1
    return ans

print solve()


Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int R;
    cin >> R;
    if (R < 1200){
        cout << "ABC" ;
    }else if(R < 2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 998244353
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

int main(void){
  ll n;
  cin>>n;
  cout<<(n-1)/2;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

string a[3] = {
    "Sunny", 
    "Cloudy", 
    "Rainy",  
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    for(int i=0;i<3;++i) {
        if(s == a[i]) {
            cout << a[(i+1)%3] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define rep(i,l,p) for(int i=l;i<=p;i++)
using namespace std;

const int maxN = 1e6 + 10;
int n;
int ar[maxN];
int a,b,d;
int flag = 0;
void input(){
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&ar[i]);
		if ( ar[i] % 2 == 0){
			if(ar[i] % 4 == 0) d++;
			else b++;
		}else{
			a++;
		}
	}
}
void solve(){
	if (d>=a && b>0) flag = 1;
	else if ( (d+1)>=a && b==0 && d>0 ) flag = 1;
}
int main(){

	input();
	solve();
	//printf("a:%d\tb:%d\td:%d\n",a,b,d );
	if (flag == 0) printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD 1000000007
#define MAX_N 10000


struct UnionFind{
    ll par[MAX_N]; // 親
    ll rank[MAX_N]; // 木の深さ
    ll siz[MAX_N]; // 素集合のサイズ

    // n要素で初期化
    void init(ll n){
        for(ll i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    // 木の根を求める
    ll root(ll x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    // xとyの属する集合を併合
    bool unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x==y) return false; // 併合失敗
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
        return true; // 併合成功
    }

    bool issame(ll x, ll y){
        return root(x)==root(y);
    }

    ll size(ll x){
        return siz[root(x)];
    }
};


int main(){
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int cnt = 0;
    rep(i, m){
        UnionFind u, v;
        u.init(n);
        v.init(n);
        rep(j, m){
            if(i!=j){
                u.unite(a[j], b[j]);
                v.unite(a[j], b[j]);
            }
        }
        v.unite(a[i], b[i]);

        set<int> su, sv;
        rep(j, n){
            su.insert(u.root(j));
            sv.insert(v.root(j));
        }
        if(su.size()==2 && sv.size()==1) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	ll cnt[5]={0,0,0,0,0};
	string s[n];
	rep(i,n){
		cin>>s[i];
		if(s[i][0]=='M'){
			cnt[0]++;
		}
		else if(s[i][0]=='A'){
			cnt[1]++;
		}
		else if(s[i][0]=='R'){
			cnt[2]++;
		}
		else if(s[i][0]=='C'){
			cnt[3]++;
		}
		else if(s[i][0]=='H'){
			cnt[4]++;
		}
	}
	ll ans=0;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=cnt[i]*cnt[j]*cnt[k];
			}
		}
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 6744
def make(n):
    C = {0: 0}
    for i in range(n):
        b = int(input(), 2)
        for k, v in dict(C).items():
            if C.get(k^b, 0) < v+1:
                C[k^b] = v+1
    return C
def calc(P, Q):
    yield 0
    for k, v in P.items():
        if k in Q:
            yield v + Q[k]
def solve():
    while 1:
        n, m = map(int, input().split())
        if n+m == 0:
            break
        yield max(calc(make(n//2), make(n-n//2)))
print(*solve(), sep="\n")


Measured memory_bytes: 13304
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


typedef pair<mp,int> mmp;

int es[105][105];
int cs[105][105];

int rs[105][105];

int main(void){
	for(;;){
		memst(es,-1);
		memst(cs,-1);
		memst(rs,-1);
		
		int n,m,l;
		scanf("%d%d%d",&n,&m,&l);
		if(n==0)break;
		
		rep(i,m){
			int a,b,c,e;
			scanf("%d%d%d%d",&a,&b,&c,&e);
			a--; b--;
			cs[a][b] = cs[b][a] = c;
			es[a][b] = es[b][a] = e;
		}
		
		pque(mmp) que;
		que.push(mmp(mp(0,0),0));
		
		while(!que.empty()){
			mmp pa = que.top();
			que.pop();
			int no = pa.sec,
				ne = pa.fir.fir,
				nc = pa.fir.sec;
			//printf("%d %d %d\n",no,nc,ne);
			rep(to,n){
				if(to==no)continue;
				int c = cs[no][to],
					e = es[no][to];
				if(c<0)continue;
				rep(k,2){
					int tc = nc,
						te = ne + e;
					if(k>0 && nc+c<=l){
						tc = nc + c;
						te = ne;
					}
					if(rs[to][tc]>=0 && rs[to][tc]<=te)continue;
					rs[to][tc] = te;
					//printf(" %d %d %d\n",to,tc,te);
					que.push(mmp(mp(te,tc),to));
				}
			}
		}
		
		int ans = IINF;
		reg(i,0,l){
			int na = rs[n-1][i];
			if(na<0)continue;
			ans = min(ans,na);
		}
		printf("%d\n",ans);
	}	
	return 0;
}

Measured memory_bytes: 3512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int dfs(int P, int Q, int A, int N, int p, int q, int x, int count) {
    if (P * q == Q * p) return 1;
    if (P * q < Q * p) return 0;
    if (count == N) return 0;

    int res = 0;
    for (int i = x; i * q <= A; i++) {
        res += dfs(P, Q, A, N, p * i + q, q * i, i, count + 1);
    }

    return res;
}

int main(void) {

    while(true) {

        int P, Q, A, N;
        cin >> P >> Q >> A >> N;

        if (!(P | Q | A | N)) break;

        int ans = dfs(P, Q, A, N, 0, 1, 1, 0);
        cout << ans << endl;

    }

    return 0;
}


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

int main(){

	int sum=0 ;
	int koka[]={1,5,10,50,100,500};
	for(int i=0;i<6;i++){
	int c;
	cin >> c;
	sum += c * koka[i];
	
	}

	cout << (sum>=1000?"1":"0") << endl;

	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b;
	cin >> a >> b;
	int x[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	cout << (x[a] == x[b] ? "Yes" : "No") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define LOG
#define PRINT
#define LCERR
#include <iostream>
auto optimize_cpp_stdio = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
    return 0;
}();
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:

private:

};

int solve() {
    Solution solution;
    int y, m, d;
    cin >> y;
    cin.get();
    cin >> m;
    cin.get();
    cin >> d;
    PRINT("{} {} {}\n", y, m, d);
    if (y > 2019 || y == 2019 && m > 4) {
        cout << "TBD\n";
    } else {
        cout << "Heisei\n";
    }
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string in1, in2; cin >> in1 >> in2;
    int in = stoi(in1+in2);
    for (int i = 0; i*i <= in; ++i) {
      if (i*i == in) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <cmath>

#define ll long long int
#define loop(v,n) for(ll v=0;v<n;v++)

using namespace std;

#define MAXN 100000

int n,k;
vector<ll> v;

int main() {
    cin >> n >> k;
    v.resize(n);
    for(int i = 0;i < n;i++) {
        int vv;
        cin >> vv;
        v[i] = vv;
    }
    ll res = 0;
    for(int r = 0;r <= k;r++)for(int l=0;l<=k;l++){
        if(r+l>k||r+l>n)continue;
        ll val = 0;
        vector<ll> d;
        for(int i = 0;i < r;i++) {
            val += v[i];
            d.push_back(v[i]);
        }
        for(int i = n-l;i<n;i++) {
            val += v[i];
            d.push_back(v[i]);
        }
        int rem = k-(r+l);
        sort(d.begin(),d.end());
        for(auto itr = d.begin();itr != d.end() && *itr < 0 && rem > 0;itr++) {
            val -= *itr;
            rem--;
        }


        res = max(res,val);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>

int main(int argc, char *argv[]){
    std::string S,T;
    std::cin >> S >> T;
    std::map<char, std::set<int> > map;
    for(int i=0; i<S.size(); ++i){
        map[S[i]].emplace(i);
    }
    int idx = -1;
    int reps = 0;
    for(const auto &t : T){
        auto &set = map[t];
        if(set.size()==0){
            std::cout << -1 << std::endl;
            return 0;
        }
        auto iter = set.upper_bound(idx);
        if(iter == set.end()){
            idx = -1;
            ++reps;
            iter = set.upper_bound(idx);
        }
        idx = *iter;
    }

    long long i = S.size();
    i *= reps;
    i += idx+1; 
    std::cout << i << std::endl;
    return 0;
}


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

#define MAX 101
#define INF INT_MAX

vector<vector<int>> adj_mat(MAX, vector<int>(MAX, INT_MAX));

void dijkstra(int start_node, int node_size){
    vector<int> visited(node_size, 0);
    vector<int> cost_table(node_size, INF);

    int node = start_node;
    cost_table.at(node) = 0;

    while(true){
        // cout << "looking node : " << node << ",  cost : ";
        // rep(i, node_size){
        //     cout << cost_table.at(i) << " "; 
        // }
        // cout << endl;

        visited.at(node) = 1;

        rep(i, node_size){
            if(visited.at(i) == 0 && adj_mat.at(node).at(i) != INF){
                int new_cost = adj_mat.at(node).at(i) + cost_table.at(node);
                if(new_cost < cost_table.at(i)){
                    cost_table.at(i) = new_cost;
                }
            }
        }

        int m = INF;
        rep(i, node_size){
            if(visited.at(i) == 0 && (cost_table.at(i) < m)){
                m = cost_table.at(i);
                node = i;
            }
        }
        if(m == INF){
            break;
        }
    }

    rep(i, node_size){
        cout << i << " " << cost_table.at(i) << endl;
    }

}

int main(){
    int n; cin >> n;
    rep(i, n){
        int u, k; cin >> u >> k;
        rep(j, k){
            int v, c; cin >> v >> c;
            adj_mat.at(u).at(v) = c;
        }
    }

    // rep(i, n){
    //     rep(j, n){
    //         if(adj_mat.at(i).at(j) == INT_MAX) cout << "∞ ";
    //         else cout << adj_mat.at(i).at(j) << " ";
    //     }
    //     cout << endl;
    // }

    dijkstra(0, n);

}



Measured memory_bytes: 3200
#include<stdio.h>
int main(){
  int i,j,a[100],v,n,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(k=0;k<n;k++){
    printf("%d",a[k]);
    if(k!=n-1)printf(" ");
  }

  printf("\n");

  for(i=1;i<n;i++){
    v=a[i];
    j=i-1;
    while(j>=0&&v<a[j]){
      a[j+1]=a[j];
      j--;  
    }
    a[j+1]=v;
    
    for(k=0;k<n;k++){
      printf("%d",a[k]);
      if(k!=n-1)printf(" ");
    }

    printf("\n");
    
  }
  
  return 0;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    vector<int> B = A;
    sort(A.rbegin(), A.rend());
    for (int i = 0; i < N;++i){
        if(B[i] == A[0]){
            cout << A[1] << endl;
        }else{
            cout << A[0] << endl;
        }
    }

        return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("APPROVED");else puts("DENIED");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n;
bool flag;
int main()
{
    sc(n);
    int x;
    flag=true;
    rep(i,1,n){
        sc(x);
        if(x%2==0){
            if(x%3!=0&&x%5!=0)flag=false;
        }
    }
    pyn(flag);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val N = sc.nextInt()
  val an = (for (i <- 1 to N) yield sc.nextInt).toList

  val Inf = Int.MaxValue >> 1
  val memo = Array.fill(N)(Inf)

  def find(x:Int):Int = {
    def iter(l:Int,r:Int):Int = {
      if (l+1==r || l==r) l
      else {
        val i = (l + r) >> 1
        (x - memo(i)) match {
          case d if d  < 0 => iter(l, i)
          case d if d == 0 => i
          case d if d  > 0 => iter(i, r)
        }
      }
    }
    iter(0, N-1)
  }

  def solver(an:List[Int]):Int = {
    if (an.isEmpty) memo.filter(_!=Inf).length
    else {
      val e = an.head
      val i = find(e)
      if (memo(i) < e) memo(i+1) = e else memo(i) = e
      solver(an.tail)
    }
  }

  println(solver(an))
 
}


Measured memory_bytes: 140900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr long long INF = (long long)1e18 + 10;

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  vector<vector<long long>> dp(3, vector<long long>(N + 2, -INF));

  if (N % 2 == 0) {
    A.insert(A.begin(), 0);
    N++;
    dp[1][0] = 0;
  } else {
    dp[0][0] = 0;
  }

  rep(i, N) {
    if (i % 2 == 0) {
      dp[0][i + 1] = dp[0][i] + A[i];
      dp[1][i + 1] = max(dp[1][i], dp[0][i]);
      dp[2][i + 1] = max(dp[2][i] + A[i], dp[1][i]);
    } else {
      dp[0][i + 1] = dp[0][i];
      dp[1][i + 1] = max(dp[1][i] + A[i], dp[0][i]);
      dp[2][i + 1] = max(dp[2][i], dp[1][i]);
    }
  }

  cout << dp[2][N] << endl;
}


Measured memory_bytes: 10388
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, i; cin >> n >> i;
    cout << (n-i+1);
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())

x=list(map(int, input().split())) 
y=list(map(int, input().split())) 

maxX=max(x)
minY=min(y)

if maxX<minY:
    if X<minY and minY<=Y:
        print("No War")
    else:
        print('War')
else:
    print('War')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin>>s;
    string t="AKIHABARA";
    int z=0;
    if(s.size()>9){
        cout<<"NO"<<"\n";
        return 0;
    }
    rep(i,16){
        int B[4]={0};
        int p=i;
        rep(j,4){
            if(p%2) B[j]=1;
            p/=2;
        }
        int x=1,a=0;
        rep(j,9){
            if(j==0&&B[0]) continue;
            if(j==4&&B[1]) continue;
            if(j==6&&B[2]) continue;
            if(j==8&&B[3]) continue;
            if(t[j]!=s[a]) x=0;
            a++;
        }
        if(x){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    cout<<"\n";
}


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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
    string s,t;
    cin>>s>>t;
    int k;
    pair<int,int> dp[s.size()][t.size()];
    if(s[0]==t[0])dp[0][0]=make_pair(1,3);
    else dp[0][0]=make_pair(0,2);
    for(int i=1;i<t.size();i++){
        if(s[0]==t[i])dp[0][i]=make_pair(1,3);
        else dp[0][i]=make_pair(dp[0][i-1].first,0);
    }
    for(int i=1;i<s.size();i++){
        if(t[0]==s[i])dp[i][0]=make_pair(1,3);
        else dp[i][0]=make_pair(dp[i-1][0].first,1);
        for(int j=1;j<t.size();j++){
            if((s[i]==t[j])&&(dp[i-1][j-1].first+1>max(dp[i][j-1].first,dp[i-1][j].first)))dp[i][j]=make_pair(dp[i-1][j-1].first+1,3);
            else{
                if(dp[i-1][j-1].first>max(dp[i][j-1].first,dp[i-1][j].first))dp[i][j]=make_pair(dp[i-1][j-1].first,2);
                else{
                    if(dp[i][j-1].first>dp[i-1][j].first)dp[i][j]=make_pair(dp[i][j-1].first,0);
                    else dp[i][j]=make_pair(dp[i-1][j].first,1);
                }
            }

        }
    }
    int a=s.size()-1,b=t.size()-1;
    string ans;
    while(a>=0&&b>=0){
        switch(dp[a][b].second){
            case 3:
                ans.push_back(s[a]);
                a--;
                b--;
                break;
            case 2:
                a--;
                b--;break;
            case 1:
                a--;break;
            case 0:
                b--;break;
        }
    }
 //   cerr<<ans;
  //  for(int i=0;i<s.size();i++){
   //     for(int j=0;j<t.size();j++)cout<<dp[i][j].second;
  //      cout<<endl;
  //  }
  //  for(int i=0;i<s.size();i++){
 //       for(int j=0;j<t.size();j++)cout<<dp[i][j].first;
 //       cout<<endl;
 //   }
    for(int i=0;i<ans.size();i++)cout<<ans[ans.size()-1-i];


   return 0;
}

Measured memory_bytes: 70528