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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long max = (long) 1e18;
            int N = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
                if (A[i] == 0) {
                    System.out.println(0);
                    return;
                }
            }

            long multi = 1;
            for (int i = 0; i < N; i++) {
                if (multi > max / A[i]) {
                    System.out.println(-1);
                    return;
                }
                multi *= A[i];
            }
            System.out.println(multi);
        }
    }
}


Measured memory_bytes: 50796
#include<iostream>
#include<algorithm>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N;
  cin >> N;
  int d[N];
  rep(i,0,N-1) cin >> d[i];
  sort(d, d+N);
  int K = d[N/2] - d[N/2-1];
  cout << K << endl;
  return 0;
}


Measured memory_bytes: 640
s = input() + '.'

count = []
pre = s[0]
c = 1
for t in s[1:] :
    if t == pre :
        c += 1
    else :
        count.append(c)
        pre = t
        c = 1
        
m = float('inf')
tot = sum(count)
now = 0
for c in count :
    now += c
    m = min(m, max(now, tot-now))
print(m)

Measured memory_bytes: 42992
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N;
ll A[310][310];
ll B[310][310];

int main() {

    cin >> N;
    REP(i,N) REP(j,N) cin >> A[i][j];
    REP(i,N) REP(j,N) B[i][j] = A[i][j];

    REP(k,N) REP(i,N) REP(j,N) {
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
    }

    REP(i,N) REP(j,N) if (A[i][j] != B[i][j]) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;

    REP(i,N) REP(j,N) ans += B[i][j];
    REP(i,N) REP(j,N) {
        bool flag = false;
        REP(k,N) {
            if (B[i][j] == B[i][k] + B[k][j] && i != k && j != k) {
                flag = true;
            }
        }
        if (flag) ans -= B[i][j];
    }

    cout << ans / 2 << endl;

    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 x = 100;
    i64 X; cin >> X;
    for (i64 i = 1; ; i++) {
        x += x / 100;
        if (x >= X) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,A,B,C;
ll T,a,b;
double v[55],D[55],Q,l,r;
ll ans;
//bool D[100005];
ll S[100005]={};
string str;
map<string,int> m;

int main(){
	cin>>A>>B>>C;
	if(B-A==C-B){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Max(xx,yy) (xx > yy ? xx : yy)
#define Min(xx,yy) (xx < yy ? xx : yy)
#define all(v) v.begin(),v.end();

template<typename... T>
void dbg(T... args) {
	#ifdef Local
    	((cout << args << " "), ...) << '\n';
    #endif
}

template<typename... T>
void print(T... args) {
    ((cout << args << " "), ...) << '\n';
}

namespace data{
    const long long n = 2 * 1e5 + 7;	
    const long long m = 0 + 7;
    const long long mod = 0;
    const long long INF = 0;
}


int main(){    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);

    #ifdef Local
    	for(int i = 1;i <= 51;i++) cout << "*\n"[i == 51];
    	cout << "Running on Halit's Computer, Good Luck Halit\n";
    	for(int i = 1;i <= 51;i++) cout << "*\n"[i == 51];
    #endif	

    long long n;
  	cin >> n;
	set<string> s;
	while(n--){
		string str;
		cin >> str;
		s.insert(str);
	}
	cout << s.size();
}	


Measured memory_bytes: 19288
S = input()

Count = {"N":0, "W":0, "S":0, "E":0}

for ch in S:
  Count[ch] += 1
  
if max(Count["N"], Count["S"]) > 0 and min(Count["N"], Count["S"]) == 0:
  print("No")
elif max(Count["E"], Count["W"]) > 0 and min(Count["E"], Count["W"]) == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll ans=0,a,b,n,t,dv,num[1000010],sum=0;
set<ll> st;
int main(){
	//freopen("in.txt","r",stdin);
	ll i;
	cin>>a>>b>>n;
	t=b%a;
	dv=b/a;
	if(t==0)
	{
		t=a;
		dv--;
	}
	for(i=0;i<t;i++)
	{
		num[(a*i)/t-a*(i/t)]++;
		st.insert((a*i)/t-a*(i/t));
	}
	for(i=0;i<a;i++)
	{
		num[i]+=dv;
		sum+=num[i];
		if(sum>n)
		{
			cout<<i<<endl;
			return 0;
		}
		if(num[i]!=0)
		{
			st.insert(i);
		}
	}
	set<ll>::iterator it=st.end();
	it--;
	cout<<*it<<endl;
	return 0;
}

Measured memory_bytes: 58220
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
const int M=1e9+7;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin>>n;
    bool cnt=0;
    while(n)
   {
     int temp=n%10;
     if(temp==7)
    {
      cnt=1;
      break;
    }
    n/=10;
  }
  if(cnt) {
  cout<<"Yes"<<"\n";
}
    else
	 cout<<"No"<<"\n";
	 
      return 0;
}

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

using namespace std;

bool isEven(int N, int a[]) {
    
    for(int i = 0; i<N; i++) {
        if(a[i]%2 != 0) {
            return false;
        }
    }

    return true;
}

int main() {

    int ans = 0;
    int N;
    cin >> N;

    int a[N];

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

    while(isEven(N, a) == true) {
        for(int i = 0; i < N; i++) {
            a[i] /= 2;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int ans,a, b, c, d;
	cin >> a >> b >> c >> d;
	ans = (a*b) > (c*d) ? (a*b) : (c*d);

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const int MOD =1000000007;

string s;
int main(void){
    cin >> s;
    ll top = 1;
    ll below = 0;
    REP(i, s.length()){
        if(s[i] == '1'){
            below = (3*below + top) % MOD;
            top = (2*top) % MOD;
        }else{
            below = (3*below) % MOD;
        }
    }

    cout << (top + below) % MOD << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
#define debug2(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define time__(d) for (auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second; debug2("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 9223372036854775800;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 62;
const long double PI = 3.141592653589793;
const int DIGITSIZE = 18;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
int x8[] = {1, 1, 1, -1, -1, -1, 0, 0};
int y8[] = {1, 0, -1, 1, 0, -1, 1, -1};
bool takeTestCases = 0;
bool printCaseNo = 0;

void getac(int T) {
	int d, t, s;
	cin >> d >> t >> s;
	int dcover = s * t;
	if (dcover >= d) {
		cout << "Yes";
	} else {
		cout << "No\n";
	}
}
int  main()
{

	fastio;
	int t = 1;
	if (takeTestCases) { cin >> t; }
	int t_t = 1;
	while (t--) {
		if (printCaseNo)
		case (t_t);
		getac(t_t);
		t_t++;
	}
	cerr << "Total time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
	return 0;
}


Measured memory_bytes: 3800
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>



int getTheAnswer() {
    return 42;
}

template< class InputIt>
void incAll(const InputIt &first, const InputIt &last){
  for(auto it = first; it != last; ++it){
    ++*it;
  }
}

template <class InputIt>
void printAll(const InputIt &first, const InputIt &last, std::ostream& out){
  for(InputIt it = first; it != last; ++it){
    out << *it << " ";
  }
}

// only for positive integers
int gcd(int a, int b){
  int tmp;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  while(b != 0){
    tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

int lcm(int a, int b){
  return abs(a*b) / gcd(a, b);
}


using namespace std;
class TaskD {
public:
	void solve(std::istream& in, std::ostream& out) {
		ios::sync_with_stdio(false);
		int n;
		string s, res;
		in >> n >> s;
		res = s;
		vector<string> test(4, s);
		test[0][0] = 'S';
		test[0][1] = 'S';
		test[1][0] = 'W';
		test[1][1] = 'S';
		test[2][0] = 'S';
		test[2][1] = 'W';
		test[3][0] = 'W';
		test[3][1] = 'W';
		for (int j = 0; j < test.size(); ++j) {
			res = test[j];
			for (int i = 2; i < n; ++i) {
				if (res[i - 1] == 'S') {
					if (s[i - 1] == 'o') {
						res[i] = res[i - 2];
					} else {
						res[i] = res[i - 2] == 'S' ? 'W' : 'S';
					}
				} else {
					if (s[i - 1] == 'x') {
						res[i] = res[i - 2];
					} else {
						res[i] = res[i - 2] == 'S' ? 'W' : 'S';
					}
				}
			}
			if (res[n - 1] == 'S') {
				if (s[n - 1] == 'o' && res[n-2] != res[0] || s[n - 1] == 'x' && res[n-2] == res[0] ) {
					continue;
				}
			} else {
				if (s[n - 1] == 'x' && res[n-2] != res[0] || s[n - 1] == 'o' && res[n-2] == res[0] ) {
					continue;
				}
			}
			if (res[0] == 'S') {
				if (s[0] == 'o' && res[n-1] != res[1] || s[0] == 'x' && res[n-1] == res[1] ) {
					continue;
				}
			} else {
				if (s[0] == 'x' && res[n-1] != res[1] || s[0] == 'o' && res[n-1] == res[1] ) {
					continue;
				}
			}
			out << res << endl;
			return;
//			if (res[0] == 'S') {
//				if (s[0] == 'o') {
//					if (res[1] == res[n - 1]) {
//						out << res << endl;
//						return;
//					}
//				} else {
//					if (res[1] != res[n - 1]) {
//						out << res << endl;
//						return;
//					}
//				}
//			} else {
//				if (s[0] == 'x') {
//					if (res[1] == res[n - 1]) {
//						out << res << endl;
//						return;
//					}
//				} else {
//					if (res[1] != res[n - 1]) {
//						out << res << endl;
//						return;
//					}
//				}
//			}
		}
		out << "-1" << endl;
	}
};


int main() {
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1104
#include <iostream>
#include <cstdio>

using namespace std;

int main() {

	int in;
	int h = 0;
	int m = 0;
	int s = 0;
	

	cin >> in;	//秒単位の時間入力

	while (in >= 3600) {
		in -= 3600;
		h++;
	}

	while (in >= 60) {
		in -= 60;
		m++;
	}

	s = in;


	cout << h << ':' << m << ':' << s << endl;

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  A[0] = -1;
  REP(i, N - 1) {
    cin >> A[i + 1];
    --A[i + 1];
  }

  vector<int> wins(N);
  REP(i, N - 1) { ++wins[A[i + 1]]; }

  vector<vector<int>> losers(N);
  REP(i, N - 1) {
    int loser = i + 1;
    int winner = A[loser];
    losers[winner].push_back(loser);
  }

  auto dfs = [&](auto rec, int v) -> int {
    vector<int> ds;
    ds.reserve(losers[v].size());
    for (auto u : losers[v]) {
      ds.push_back(rec(rec, u));
    }
    int maxdepth = wins[v];
    sort(ds.rbegin(), ds.rend());
    REP(i, ds.size()) {
      int d = ds[i] + i + 1;
      if (maxdepth < d) maxdepth = d;
    }
    return maxdepth;
  };
  int maxdepth = dfs(dfs, 0);
  cout << maxdepth << endl;
}


Measured memory_bytes: 28156
#include <stdio.h>

int main(void)
{
int n,i,j,a,b;
long int y;

scanf("%d %ld", &n,&y);

for (i = 0; i <= n; i++){
for (j = 0; j <= n; j++){
a = (y-(10000*i+5000*j))%1000;
b = (y-(10000*i+5000*j))/1000;
if ((a == 0)&&(b+i+j == n)&&(b >= 0)){
printf("%d %d %d\n", i, j, b);
return 0;
}
}
}
printf("-1 -1 -1\n");

return 0;
}

Measured memory_bytes: 128
'use strict'

function Main(input) {
  input = input.trim().split('\n')
  const N = input[0]
  const res = input.slice(1)

  let memo = {}

  res.forEach(s => {
    if(!memo[s]) memo[s] = 0
    memo[s] += 1
  })

  let max = 0
  for (let i in memo) {
    if (max < memo[i]) max = memo[i]
  }

  let results = []
  for(let i in memo) {
    if (memo[i] === max) {
      results.push(i)
    }
  }

  results = results.sort()

  let str = results.reduce((pre, curr) => pre += curr + '\n', '')
  str = str.trim()
  console.log(str)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 117588
using System;

class AOJ {
    static void Main(string[] args)
    {
        int h, m, s;
        int S = int.Parse(Console.ReadLine());

        h = S / 3600;
        m = S / 60 % 60;
        s = S % 60;

        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}

Measured memory_bytes: 9200
#include<stdio.h>
	   const int MAX_V = 1000000;
	   int prime[MAX_V+1];
	   int sum[MAX_V+1];
	   int main(){
	   	int i,k,v,m=2,cnt=0;
	   	for(i=m;i<=MAX_V;i++){
	   		prime[i]=1;
	   	}
	   	for(i=m;i*i<=MAX_V;i++){
	   		if(prime[i]){
	   			for(k=2*i;k<=MAX_V;k+=i){
	   				prime[k]=0;
	   			}
	   		}
	   	}
	   	for(i=0;i<MAX_V+1;i++){
	   	 sum[i+1]=sum[i]+prime[i];
	   	}
	   	while(scanf("%d",&v)!=EOF){
	   	 printf("%d\n",sum[v+1]);
	   	}
	   	return 0;
	   }

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

void chmax(int& a, int b) {
  if (a < b) a = b;
}

int main() {
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  
  int x = 0;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'I') {
      x++;
    } else {
      x--;
    }
    
    chmax(ans, x);
  }
  
  cout << ans << endl;
}

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 2e9;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  int sum = 0;
  for (int i=0; i<=n; ++i) {
    if (i%3 == 0 || i%5 == 0)
      continue;
    sum += i;
  }
  cout << sum << endl;
}


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

using namespace std;

int main(){
    string a, b, c; cin >> a >> b >> c;

    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using namespace std;

typedef struct p{
    char name[100];
    int time;
} process;

process Q[LEN], res[LEN];
int head, tail;

void enqueue(process x) {
    Q[tail] = x;
    tail = (tail+1) % LEN;
}

process dequeue() {
    process temp = Q[head];
    head = (head+1) % LEN;
    return temp;
}

bool isEmpty() {
    return head == tail;
}

int main()
{
    int elaps = 0, flag = 0;
    int n, q;
    scanf("%d %d", &n, &q);

    for(int i = 0; i < n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].time);

        enqueue(Q[i]);
    }

    while(!isEmpty()) {
        process temp = dequeue();

        if(temp.time - q <= 0) {
            elaps = elaps + temp.time;
            strcpy(res[flag].name, temp.name);
            res[flag].time = elaps;
            flag++;
        }else {
            elaps = elaps + q;
            temp.time = temp.time - q;
            enqueue(temp);
        }
    }

    for(int i = 0; i < n; i++) {
        printf("%s %d\n", res[i].name, res[i].time);
    }

    return 0;
}

Measured memory_bytes: 17804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

const ll MOD = (1e9 + 7);

void solver(int N, vector<ll> &A, ll &ans){

    vector<ll> c_sum(N);
    c_sum.at(N-1) = A.at(N-1);
    for(int i = N-2; i != -1; --i){
        c_sum.at(i) += (A.at(i)%MOD) + c_sum.at(i+1)%MOD;
    }
    /*
    for(int i = 0; i != N; ++i){
        cerr << c_sum.at(i) << " "s;
    }
    cerr << endl;
    */

    ll ans_buf{};
    //int pos = 1;
    for(int i = 0; i != N-1; ++i){
        ans_buf += ((A.at(i)%MOD)*(c_sum.at(i+1)%MOD))%MOD;
        ans_buf %= MOD;
        //++pos;
    }
    ans = ans_buf;

    return;    
}

int main(){

    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i != N; ++i) cin >> A.at(i);

    ll ans;
    solver(N, A, ans);

    cout << ans << endl;

    return 0;
}


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

int main(){
    while(1){
        int n,m,k;
        cin >> n >> m >> k;
        if(n == 0) break;

        vector<double> dp(n*m+1, 0);
        dp[0] = 1;
        for(int i=0; i<n; i++){
            vector<double> ndp(n*m+1, 0);
            for(int j=0; j<=i*m; j++){
                for(int d=1; d<=m; d++){
                    ndp[j+d] += dp[j]/m;
                }
            }
            dp = ndp;
        }
        double ans = 0;
        for(int i=0; i<=n*m; i++){
            int bill = max(1, i-k);
            ans += bill*dp[i];
        }
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3408
# original: https://atcoder.jp/contests/diverta2019-2/submissions/6023476

inpl = lambda: list(map(int,input().split()))
N = int(input())
rate = []
rate.append(inpl())
rate.append(inpl())
ABc = []
ABr = []
BAc = []
BAr = []
for i in range(3):
    rA, rB = rate[0][i], rate[1][i]
    if rB > rA:
        ABc.append(rA)
        ABr.append(rB)
    elif rA > rB:
        BAc.append(rB)
        BAr.append(rA)

dpAB = [0]*(N+1)
q = [0]*(len(ABc)+1)
for i in range(1,N+1):
    dpAB[i] = dpAB[i-1]+1
    for j in range(len(ABc)): #cost, ret in AB:
        if i >= ABc[j]:
            dpAB[i] = max(dpAB[i], dpAB[i-ABc[j]] + ABr[j])

M = dpAB[N]
dpBA = [0]*(M+1)
q = [0]*(len(BAc)+1)
for i in range(1,M+1):
    k = 1
    dpBA[i] = dpBA[i-1]+1
    for j in range(len(BAc)):
        if i >= BAc[j]:
            dpBA[i] = max(dpBA[i], dpBA[i-BAc[j]] + BAr[j])

print(dpBA[M])


Measured memory_bytes: 230552
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,k=0;
	cin>>a;
	int res,i,j,temp=0,temp2;
		for(i=1;i<10;i++){
		for(j=1;j<10;j++){
		res=i*j;
		if(res==a)temp=1;

		}
	}
	if(temp==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
cards = [[False for i in range(13)] for j in range(4)]
n = int(input())
pattern = ["S", "H", "C", "D"]
for i in range(n):
    a, b = input().split()
    b = int(b)
    cards[pattern.index(a)][b - 1] = True
    
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j + 1)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define pii pair < int , int >
#define DB printf("debug\n");
#define all(x) x.begin() , x.end()
#define forr(i,A,B) for(int i=A;i<B;++i)
using namespace std;
vector<int>e[200005];
int maxd,maxdv;
void dfs(int vn,int pv,int dn){
	if(dn>maxd){
		maxd=dn;
		maxdv=vn;
	}
	for(int i=0;i<e[vn].size();i++){
		if(e[vn][i]!=pv){
			dfs(e[vn][i],vn,dn+1);
		}
	}
}

int main(){
	cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);

	int n;
	cin>>n;

	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		e[a].pb(b);
		e[b].pb(a);
	}

	maxd=-1;
	maxdv=-1;
	
	dfs(1,1,0);

	int dia1=maxdv;
	maxdv=-1;
	maxd=-1;

	dfs(dia1,dia1,0);

	int dia2=maxdv;
	int dia=maxd;


	int dp[n+5];
	dp[0]=dp[2]=0;
	dp[1]=dp[3]=1;
	for(int i=4;i<=dia+1;i++){
		if(dp[i-1]==0 or dp[i-2]==0){
			dp[i]=1;
		}
		else{
			dp[i]=0;
		}
	}

	cout<<(dp[dia+1] == 1 ? "First" : "Second")<<endl;


	return 0;
}

Measured memory_bytes: 23680
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
	double EPS = 1.0e-08;
	int MAX = 1000000;
	int [] acc;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		init();
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int m = sc.nextInt();
			int ans = acc[m] - acc[n-1];
			System.out.println(ans);
		}
	}
	
	private void init(){
		acc = new int[MAX + 1];
		boolean [] isH = new boolean[MAX+1];
		isH[1] = true;
		for(int i = 1; i <= MAX; i++){
			if(isH[i]){
				for(int j = 2; j <= 5; j++){
					if(j == 4) continue;
					int ind = i * j;
					if(ind > MAX) break;
					isH[ind] = true;
				}
				acc[i] += acc[i-1] + 1;
			}
			else{
				acc[i] += acc[i-1];
			}
		}
	}
	
	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 24776
package main

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

func main() {
	sc := NewScanner()
	A, P := sc.NextInt(), sc.NextInt()
	fmt.Println((A*3 + P) / 2)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int mn = 1e9, ans = 0;
    rep(i, n)
    {
        mn = min(mn, p[i]);
        if (mn == p[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include<stdio.h>
int main(void)
{
    int i,N,countR=0,countB=0;
    char M,s[99];
    
    scanf("%d",&N);
    scanf("%c",&M);
    
    for(i=0;i<N;i++){
        scanf("%c",&s[i]);
    }
    
    for(i=0;i<N;i++){
        if(s[i]=='R')
            countR++;
        else
            countB++;
        
    }
    if(countR>countB)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main(){
	long n, m;
	long max;
	long sum;
	long i, j;
	long* list;
	
	while( 1 ){
		scanf( "%ld %ld", &n, &m );
		if(( n == 0) && ( m == 0 )){
			break;
		}
		list = ( long* )malloc( sizeof( long ) * n );
		for( i = 0; i < n; i++ ){
			scanf( "%ld",  (list + i ));
		}
		
		max = 0;
		for( i = 0; i < n; i++ ){
			for( j = i + 1; j < n; j++ ){
				sum = *( list + i ) + *( list + j );
				if( max < sum && m >= sum )max = sum;
			}
		}
		
		if( max == 0 ){
			printf( "NONE\n" );
		}
		else{
			printf( "%ld\n", max);
		}
		free( list );
	}
	return 0;
}




Measured memory_bytes: 2044
def heisei():
  print('Heisei')
  exit(0)


def tbd():
  print('TBD')
  exit(0)


s = input()

y = int(s[0:4])
m = int(s[5:7])
d = int(s[8:10])

if y < 2019:
  heisei()
elif y == 2019:
  if m < 4:
    heisei()
  elif m == 4:
    if d <= 30:
      heisei()

tbd()


Measured memory_bytes: 3060
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A = nextInt();
		int B = nextInt();
		out.println(6-A-B);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 2e5 + 5;
int t;

int main()
{
//	freopen("in.txt", "r", stdin);
	int x, n,y;
	while (cin >> x >> n)
	{
		unordered_set<int> st;
		f(i, 1, n)scanf("%d", &y), st.insert(y);
		int mi = 2e9;
		int ans = 100;
		f(i, -1, 101)
		{
			if (!st.count(i))
			{
				//debug(i);
				if (mi > abs(x - i))
				{
					ans = i;
					mi = abs(x - i);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
int n; cin >> n;
int Min = 1<<30, Max = 0;
for (int i = 0; i < n; ++i) {
int a; cin >> a;
Min = min(Min, a);
Max = max(Max, a);
}
cout << Max - Min << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private Set<Integer> createSet(int M) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i <= M; i++) {
            set.add(i);
        }
        return set;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[] ok = new boolean[M + 1];
        Arrays.fill(ok, true);

        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        }

        System.out.println(cnt);

        return;
    }

}

Measured memory_bytes: 23252
import sys

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 9 + 7


n, k = list(map(int, sys.stdin.readline().split()))
graph = [dict() for i in range(n)]
for i in range(n):
    graph[i]["eda"]=[]
for i in range(n - 1):
    a, b = list(map(int, sys.stdin.readline().split()))
    graph[a - 1]["eda"].append(b - 1)
    graph[b - 1]["eda"].append(a - 1)
ans = 1
check = [False] * n
stack = [0]
ans = 1
while len(stack) > 0:
    x = stack.pop()
    check[x] = True
    count = 0
    for i in graph[x]["eda"]:
        if not check[i]:
            count += 1
            stack.append(i)
    if x == 0:
        temp = 1
        for i in range(count):
            temp = temp * (k - 1 - i) % INF
        ans = ans * temp % INF
    else:
        temp = 1
        for i in range(count):
            temp = temp * (k - 2 - i) % INF
        ans = ans * temp % INF
print((ans * k) % INF)

Measured memory_bytes: 91440
#include <stdio.h>

int main(void){
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  if(A*B>=C*D){
    printf("%d\n",A*B);
  } else{
    printf("%d\n",C*D);
  }
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int N;
string s, t;

int main() {
    cin >> N >> s >> t;
    int ans = 2 * N;
    REPR(i, N) {
        string tp = t.substr(0, i);
        if(s.find(tp) == N - i) {
            ans -= i;
            break;
        }
    }
    cout << ans << "\n";
}


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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int a;
  cin>>a;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<a;i++){
    if(vec.at(i)%2==0){
      if(vec.at(i)%3!=0&&vec.at(i)%5!=0){
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;
}

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

int main(){
  int A, B, i, count = 0;
  cin >> A >> B;
    
  while (i < 1009){
    
    if (i * 2 / 25 == A && i / 10 == B){
      cout << i << endl;
      break;
    }
    else{
       count++;
    }
  
    i++;
  }
  
  if (count == 1009){
    cout << "-1" << endl;
  }
}
    


Measured memory_bytes: 256
import math
(n,),p,q=[list(map(int, i.split())) for i in open(0)]
def c(l):
    s=0
    t=list(range(1,n+1))
    for i in range(n):
        s+=t.index(l[i])*math.factorial(n-i-1)
        t.remove(l[i])
    return s
print(abs(c(p)-c(q)))

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;

  int64_t st = 0, en = s.size() - 1;

  while (s[st] != 'A') {
    st++;
  }
  while (s[en] != 'Z') {
    en--;
  }

  std::cout << en - st + 1 << std::endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int l = scanner.nextInt();
        long[][] A = new long[(n)][(m)];
        long[][] B = new long[(m)][(l)];
        long[][] C = new long[(n)][(l)];

        for (int i = 0; n > i; i++) {
            for (int j = 0; m > j; j++) {
                int a = scanner.nextInt();
                A[i][j] = a;
            }
        }

        for (int i = 0; m > i; i++) {
            for (int j = 0; l > j; j++) {
                int a = scanner.nextInt();
                B[i][j] = a;
            }
        }

        for (int i = 0; n > i; i++) {
            for (int j = 0; m > j; j++) {
                for (int k = 0; l > k; k++) {
                    C[i][k] += A[i][j] * B[j][k];
                }
            }
        }

            for (int i = 0; n > i; i++) {
                for (int j = 0; l > j; j++) {
                    if (j != (l-1)) {
                        System.out.print(C[i][j]+" ");
                    } else {
                        System.out.println(C[i][j]);
                    }
                }
            }
        }
    }

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

def main():
    S = input().strip()

    ma = 0
    prev = ""
    a = []
    a.append(0)
    total = 0
    for i, s in enumerate(S):
        if prev == ">" and s == "<":
            if a[i] > 0:
                total -= (ma - a[i]) * a[i]
            elif a[i] < 0:
                total -= (ma - a[i] + 1) * a[i]
            a.append(1)
            ma = 1
        elif s == "<":
            ma += 1
            a.append(a[i] + 1)
        elif s == ">":
            a.append(a[i] - 1)

        prev = s


    if S[-1] == ">":
        if a[-1] > 0:
            total -= (ma - a[-1]) * a[-1]
        elif a[-1] < 0:
            total -= (ma - a[-1] + 1) * a[-1]

    print(total + sum(a))

if __name__ == '__main__':
    main()




Measured memory_bytes: 24092
import java.util.Scanner;

public class Main {

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

    private static void solve(Scanner in) {
        in.useDelimiter("\\D");
        int w = in.nextInt();
        int n = in.nextInt();
        int[] amida = new int[w + 1];
        for (int i = 1; i < amida.length; i++) {
            amida[i] = i;
        }
        while (n --> 0) {
            int a = in.nextInt();
            int b = in.nextInt();

            int tmp = amida[a];
            amida[a] = amida[b];
            amida[b] = tmp;
        }
        for (int i = 1; i < amida.length; i++) {
            System.out.println(amida[i]);
        }
    }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    string c;
    cin >> c;
    int a = 0, b = 0;
    rep(i, n) if (c[i] == 'R') ++a;
    int ans = max(a, b);
    rep(i, n) {
        if (c[i] == 'R') --a;
        if (c[i] == 'W') ++b;
        ans = min(ans, max(a, b));
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3756
import sys
def input():
	return sys.stdin.readline().strip()



N, M = list(map(int, input().split()))

ab_list = []
c_list = []

for _ in range(M):
	ab_list.append(tuple(map(int, input().split())))
	c = tuple(map(int, input().split()))
	sum = 0
	for ci in c:
		sum += 2**(ci - 1)
	c_list.append(sum)

dp = [[10**10]*(2**N) for _ in range(M + 1)]

dp[0][0] = 0

for m in range(0, M):
	for i in range(2**N):
		if dp[m][0] < 10**10:
			loc_next = i | c_list[m]
			dp[m + 1][loc_next] = min(dp[m + 1][loc_next], dp[m][i] + ab_list[m][0])
			dp[m + 1][i] = min(dp[m + 1][i], dp[m][i])

if dp[M][-1] < 10**10:
	print(dp[M][-1])
else:
	print(-1)

Measured memory_bytes: 75608
#include<iostream>
#include<algorithm>
using namespace std;
int H,W,K;
string s[30];
int A[30][30];
int calc()
{
	int ret=0;
	for(int z=0;;z++)
	{
		int now=0;
		bool f[30][30]={};
		for(int i=0;i<H;i++)
		{
			int cnt=0,pre=-1;
			for(int j=0;j<W;j++)
			{
				if(A[i][j]==0)
				{
					cnt=0;
					pre=-1;
				}
				else
				{
					if(pre==A[i][j])cnt++;
					else cnt=1;
					pre=A[i][j];
				}
				if(cnt>K)
				{
					f[i][j]=true;
					now+=A[i][j];
				}
				else if(cnt==K)
				{
					for(int k=0;k<K;k++)
					{
						f[i][j-k]=true;
						now+=A[i][j-k];
					}
				}
			}
		}
		if(now==0)break;
		ret+=now<<z;
		for(int j=0;j<W;j++)
		{
			int sz=H;
			for(int i=H;i--;)
			{
				if(A[i][j]==0||f[i][j])continue;
				A[--sz][j]=A[i][j];
			}
			while(sz)A[--sz][j]=0;
		}
	}
	return ret;
}
main()
{
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)cin>>s[i];
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)A[i][j]=s[i][j]-'0';
	int ans=calc();
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)A[i][j]=s[i][j]-'0';
		for(int k=i;k--;)A[k+1][j]=A[k][j];
		A[0][j]=0;
		ans=max(ans,calc());
	}
	cout<<ans<<endl;
}


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

int main(){
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if(r<=x && x<=w-r && r<=y && y<=h-r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}



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

int main(void)
{
    int N;

    cin >> N;

    vector<int> A(N);

    rep(i, N)
            cin >> A[i];

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

    cout << A.back() - A.front() << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	int n, m;
	long long int ans = 0;
	cin >> n >> m;
	priority_queue<int> q;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		q.push(a);
	}

	for (int i = 0; i < m; i++) {
		int a = q.top();
		q.pop();
		a = a / 2;
		q.push(a);
			}
	while (q.size()) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
	
}

Measured memory_bytes: 3936
#include <iostream>
#include <algorithm>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int p[509][509]={{}};
int main(){
	int n,m,q; cin >>n>>m>>q;
	for(int i=1;i<=m;i++){
		int l,r;
		cin >>l>>r;
		p[l][r]++;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			p[i][j]+=p[i][j-1];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			p[i][j]+=p[i-1][j];
		}
	}
	for(int i=1;i<=q;i++){
		int l,r; cin >>l>>r;
		cout << p[r][r] -p[l-1][r] -p[r][l-1]+p[l-1][l-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1920
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (a, b, c): (isize, isize, isize) = parse!(it, 3);
    let r = c - a - b;
    if r >= 0 && r.pow(2) > 4 * a * b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352