akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint rnk(n);
    vint sum(n+1);
    REP(i,n){
        int p;
        cin >> p;
        rnk[p-1] = i+1;
    }
    REP(i,n){
        sum[i+1] = sum[i]+rnk[i];
    }
    vint a(n);
    vint b(n);
    REP(i,n){
        a[i]=n-i;
        b[i]=i+1;
        a[i]+=sum[n]-sum[i];
        b[i]+=sum[i+1];
    }
    REP(i,n){
        cout << b[i] << ((i==n-1)?("\n"):(" "));
    }
    REP(i,n){
        cout << a[i] << ((i==n-1)?("\n"):(" "));
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}

int main(){
  ll N; cin >> N;
  ll a[N]; REP(i,N){cin >> a[i];}
  ll b[N]; REP(i,N){cin >> b[i];}
  ll d[N]; REP(i,N){d[i] = a[i]-b[i];}
  sort(d,d+N);
  ll left_p = 0;
  ll left = d[0];
  ll right_p = N-1;
  ll right = d[right_p];
  
  ll r = -1;
  bool can = true;
  while(1){
    //printf("%Ld %Ld\n",right,left);
    if(right+left>0){
      if(left>=0){break;}
      right += left;
      left_p++;
      left = d[left_p];
      if(left>=0){break;}
    }else if(right+left==0){
      left_p++;
      left = d[left_p];
      right_p--;
      right = d[right_p];
      if(left>=0){break;}
      else if(right<=0){can = false;break;}
    }else{
      if(right<=0){can = false;break;}
      left += right;
      right_p--;
      right = d[right_p];
      if(right<=0){can = false;break;}
    }
  }
  if(can){
	r = left_p + (left != d[left_p]);
  	r += N-1-right_p + (right != d[right_p]);
  }
  cout << r << "\n";
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

int F(int a, int b, int c){
	return (a*c+b) % 26;
}

int main(){
	int n;
	string str1;
	getline(cin,str1);

	n = atoi(str1.c_str());
	for(int i=0;i<n;i++){
		string str2;
		getline(cin,str2);

		for(int a=0;a<100;a++){
			for(int b=0;b<100;b++){
				string tmp = str2;
				for(int i=0;i<str2.size();i++){
					if(tmp[i]=='.') continue;
					if(tmp[i]==' ') continue;
					if(isdigit(tmp[i])) continue;
					tmp[i] = F(a,b,str2[i]-'a') + 'a';
				}

				if(tmp.find("that") != string::npos
					|| tmp.find("this") != string::npos){
						cout << tmp << endl;
						goto found;
				}
			}
		}
found:;
	}
}

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


int main(){
    int n; cin>>n;
    int a[100005]={0};
    long long sum=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        sum+=x;
        a[x]++;
    }
  int q; cin>>q;
    for(int i=0;i<q;i++){
        int b,c; cin>>b>>c;
        sum+=(c-b)*a[b];
        a[c]+=a[b];
        a[b]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    vel a(N); 
    rep(i,N) {
        cin >> a[i];
        if(a[i] % 2 == 1) cnt1++;
        else if (a[i] % 4 == 0) cnt4++;
        else cnt2++;
    }

    if(N % 2 == 1) {
        if(cnt1 > cnt4+1 ) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    else {
        if(cnt1 > cnt4) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >> H >> W;
       if(H==0 && W==0){
           break;
       } 
        for(int j = 0; j<H; j++){
            for(int i =0; i<W; i++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    // cout << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
#include <atcoder/all>
using namespace std; using namespace atcoder;
using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;
int main() {
	cin >> N >> M;
	scc_graph G(N);
	for (i = 0; i < M; i++) {
		ll a, b;
		cin >> a >> b;
		G.add_edge(a, b);
	}
	auto scc = G.scc();
	co(scc.size());
	for (auto v : scc) {
		co3(v.size());
		for (ll x : v) co3(x);
		cout << endl;
	}
}

Measured memory_bytes: 40608
n,y=map(int,input().split())
y//=1000
res=False
ans=["-1","-1","-1"]
for i in range(n+1):
    for j in range(n+1-i):
        if 10*i+5*j+(n-i-j)==y:
            ans=[str(i),str(j),str(n-i-j)]
            res=True
            break
    if res:
        break

print(" ".join(ans))


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

int main(){
    
    int n,k;
    cin>>n>>k;
    
    vector<int> dp(n);
    vector<int> v(n);
    
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    
    dp[0] = 0;
    for(int i=1; i<n; i++){
        
        dp[i] = INT_MAX;
        for(int j=1; j<=k && j<=i; j++){
        int q = dp[i-j]+ abs(v[i]-v[i-j]);
        if(dp[i]>q) dp[i] = q;
        }
    }
    
    cout<<dp[n-1]<<endl;
    
    
}

Measured memory_bytes: 4012
#include<iostream>
#include<algorithm>
using namespace std;
long long i,n,maxn=-1000000001,minn=1000000001,s;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++) 
	{
		cin>>s; 
		if(maxn<s) maxn=s; 
		if(minn>s) minn=s;
	}
	cout<<maxn-minn;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N, K; cin>>N>>K;
    if((N-1)*(N-2)/2<K){
        cout<< -1 << endl;
        return 0;
    }
    vector<P> E;
    for(ll i=1; i<N; i++){
        E.push_back(P(0, i));
    }
    ll cnt = (N-1)*(N-2)/2;
    for(ll i=1; i<N and cnt>K; i++){
        for(ll j=i+1; j<N and cnt>K; j++){
            E.push_back(P(i, j));
            cnt--;
        }
    }
    cout << E.size() << endl;
    REP(i, E.size()){
        cout << E[i].first + 1 << " " << E[i].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 512
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); IO();
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b)
{
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans *= a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}

ll powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

void IO()
{
	#ifndef ONLINE_JUDGE
		freopen("Input.txt", "r", stdin);
		freopen("Output.txt", "w", stdout);
	#endif
}

//================================

int main()
{
	// FAST;

	string s;
	cin >> s;

	if (s.find('7') != string :: npos)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
    int a=0,b=0,c=0,d=0,ca=0,no=0;
    cin>>a;
    int x[a];
    for(int i=0;i<a;i++){
        cin>>x[i];
        b=x[i]%2;
        if(b==0){
            c=x[i]%3;
            d=x[i]%5;
            if(c!=0&&d!=0){
               // ca++;
                no++;
            }
        }
    }
  
    if(no>0){
        cout<<"DENIED";
    }else{
        cout<<"APPROVED";
    }
    cout<<endl;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void){

int H,W,i,t;

for(;;){
scanf("%d %d",&H,&W);

if(H==0&&W==0){
break;
}


	for(i=1;i<=H;i++){
		printf("#");
		for(t=3;t<=W;t++){
			if(i==1||i==H){
				printf("#");
			}else{
				printf(".");
			}
		}
		printf("#");
		printf("\n");
	}
	printf("\n");
}

 return 0;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N;
string s[310], t[310];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) {
    cin >> s[i];
    t[i] = s[i];
  }
  int ans = 0;
  REP(d, N) {
    REP(i, N) REP(j, N) t[(i+d)%N][j] = s[i][j];
    int flag = 1;
    REP(i, N) REP(j, N) {
      flag &= t[i][j] == t[j][i];
    }
    ans += flag*N;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;

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

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

const int INF = 1 << 30;

int main()
{
  int num = 100000;
  vector<int> dp(num + 1, INF);
  dp[0] = 0;

  for (int i = 0; i < num; i++)
  {
    chmin(dp[i + 1], dp[i] + 1);
    for (int j = 1; i + pow(6, j) <= num; j++)
    {
      chmin(dp[i + pow(6, j)], dp[i] + 1);
    }
    for (int j = 1; i + pow(9, j) <= num; j++)
    {
      chmin(dp[i + pow(9, j)], dp[i] + 1);
    }
  }

  int N;
  cin >> N;
  cout << dp[N] << endl;
}

Measured memory_bytes: 896
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parsing")
}

fn main() {
  let a: i64 = read::<i64>();
  let b: i64 = read::<i64>();
  let k: i64 = read::<i64>();

  let s: i64 = a - k;

  if s <= 0 {
    let t = b + s;
    if t <= 0 {
      println!("0 0");
    } else {
      println!("0 {}", t);
    }
  } else {
    println!("{} {}",s, b);
  }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
vector <ll> factorials, inv_factorials;

ll mod=1e9+7;

ll modExp(ll x, ll n)
{
    if (n<0) return 0;
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll modInv(ll a)
{
    return modExp(a, mod-2);
}

void calculate(ll N)
{
    factorials.resize(N+1);
    inv_factorials.resize(N+1);
    factorials[0]=1;
    for (int i=1; i<=N; ++i) factorials[i]=(factorials[i-1]*i)%mod;
    inv_factorials[N]=modInv(factorials[N]);
    for (int i=N-1; i>=0; --i) inv_factorials[i]=((i+1)*inv_factorials[i+1])%mod;
}

ll choose(ll N, ll K)
{
    if (N<0 || K<0) return 0;
    if (K>N) return 0;
    return (((factorials[N]*inv_factorials[N-K])%mod)*inv_factorials[K])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    cout << ((modExp(10,N) + modExp(8,N) - 2*modExp(9,N))%mod+mod)%mod << "\n";
    return 0;
}

Measured memory_bytes: 3652
main(a,b,c,i,x,y,A){
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  for(A=a*x+b*y,i=0;i<=(x>y?x:y);i++)A=(A<2*c*i+a*(x-i>0?x-i:0)+b*(y-i>0?y-i:0)?A:2*c*i+a*(x-i>0?x-i:0)+b*(y-i>0?y-i:0));
  printf("%d",A);
}

Measured memory_bytes: 1712
/*
*
*Problem Link : https://atcoder.jp/contests/dp/tasks/dp_f
*Platform: atcoder
*Status: correct
*Author: Mayukh Chakrabarti
*
*/

#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false)
#define boost cin.tie(NULL)
#define booster cout.tie(NULL)
#define endl "\n"
typedef long long int lld;

#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

using namespace std;

class Solution {
public:
    string longestCommonSubsequence(string text1, string text2) {
        int n= text1.length();
        int m= text2.length();
        
        vector<vector<int>> dp(n+1 , vector<int>(m+1 , 0));
        
        for(int i=1; i<=n ; i++){
            
            for(int j=1; j<=m; j++){
                
                if(text1[i-1] == text2[j-1])
                    dp[i][j]= 1 + dp[i-1][j-1];
                else
                    dp[i][j]= max(dp[i-1][j] , dp[i][j-1]);
            }
        }
        
        //int len= dp[n][m];
        
        string s="";
        
        int i=n;
        int j=m;
        
        while (i > 0 && j > 0) 
   		{ 
      		// If current character in X[] and Y are same, then 
      		// current character is part of LCS 
      		if (text1[i-1] == text2[j-1]) 
      		{ 
         		s = text1[i-1] + s; // Put current character in result 
          		i--; j--;      // reduce values of i, j and index 
      		} 
  
      		// If not same, then find the larger of two and 
	    	// go in the direction of larger value 
      		else if (dp[i-1][j] > dp[i][j-1]) 
         		i--; 
      		else
         		j--; 
   		} 
		
		return s;
    }
};

int main(){
	
	speed;boost;
	
	string s;
	string t;
	cin>>s>>t;
	
	Solution res;
	
	cout<<res.longestCommonSubsequence(s,t);
	
	return 0;
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==0) return 1;
	ll rtn=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) rtn=rtn*m%mod;
	return rtn;
}

int main(){
	string s;
	cin >> s;
	int n=s.length();

	vector<ll> ca(n+1, 0), cc(n+1, 0), c(n+1, 0);
	for(int i=0; i<n; i++){
		ca[i+1]=ca[i];
		cc[i+1]=cc[i];
		c[i+1]=c[i];
		if(s[i]=='A') ca[i+1]++;
		else if(s[i]=='C') cc[i+1]++;
		else if(s[i]=='?') c[i+1]++;
	}

	ll ans=0;
	for(int i=1; i<=n; i++){
		if(s[i-1]=='B' || s[i-1]=='?'){
			ll tmp1=(ca[i-1]*(cc[n]-cc[i]))%mod*(pmod(3, c[i-1]+(c[n]-c[i])))%mod;
			ll tmp2=(ca[i-1]*(c[n]-c[i])%mod)*(pmod(3, c[i-1]+(c[n]-c[i]-1)))%mod;
			ll tmp3=(c[i-1]*(cc[n]-cc[i])%mod)*(pmod(3, (c[i-1]-1)+(c[n]-c[i])))%mod;
			ll tmp4=(c[i-1]*(c[n]-c[i])%mod)*(pmod(3, (c[i-1]-1)+(c[n]-c[i]-1)))%mod;
			ans=(ans+tmp1+tmp2+tmp3+tmp4)%mod;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	int e = abs(a - b);
	for (int i = 0; i < n; i++) {
		//iプラス
		int j = n - 1 - i;
		int MIN = c*i + (-d*j);
		int MAX = d*i + (-c*j);
		if (e >= MIN&&e <= MAX) { puts("YES"); return 0; }
	}
	puts("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define testcase() int t; cin>>t; while(t--)
#define fo(n) for (int i = 0; i < n; i++)
#define deb(x) cout << #x << " = " << x << endl;
#define ll long long

using namespace std;

void solve()
{
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z')
        cout << "A" << endl;
    else
        cout << "a" << endl;
}

int main()
{
    //testcase()
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3588
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

kill_score = 0
for i in range(n):
    if a[i] >= b[i]:
        kill_score += b[i]

    else:
        if a[i] + a[i + 1] <= b[i]:
            kill_score += a[i] + a[i + 1]
            a[i + 1] = 0
        else:
            a[i + 1] -= b[i] - a[i]
            kill_score += b[i]


print(kill_score)
#print(a)

Measured memory_bytes: 19116
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()
	val array = f.readLine().split(" ").map{it.toInt()}.toIntArray().sorted()

	val MAXA = 1000005
	val remaining = BooleanArray(MAXA){true}

	var answer = 0
	for(k in 0 until n){
		if(remaining[array[k]] && !(k < n-1 && array[k+1] == array[k])) answer++
		if(k > 0 && array[k-1] == array[k]) continue
		for(j in array[k] until MAXA step array[k]) remaining[j] = false
	}

	println(answer)

}


Measured memory_bytes: 70468
/**
 * Created by karayuu on 2018/07/03
 */
fun main(args: Array<String>) {
    var (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val dislikeNums = readLine()!!.split(" ")
    var n_s = n.toString().map { it.toString() }

    while (!n_s.none { dislikeNums.contains(it) }) {
        n++
        n_s = n.toString().map { it.toString() }
    }

    print(n)

}


Measured memory_bytes: 47988
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
        cout << s << "\n";
    else
        cout << "red" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  ll val=c-(a-b);
  if(val>=0)
  {
    cout<<val;
  }
  else
  {
    cout<<0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<string>
#include<array>
#include <utility>
#include <algorithm>
#include <map> // pair
#include <iostream>
using namespace std;

int main(){
  int n, m;
  scanf("%d", &n); scanf("%d", &m);
  int a[n+3]; int b[n+3];

  vector<pair<int, int>> shops(n);

  for(int i = 0; i < n; i++) {
    int a, b;
     scanf("%d", &a);  scanf("%d", &b);
     shops[i] = make_pair(a, b);
  }

  //pair<int, int> shop[];
  
  // for(int i = 0; i < n; i++){
  //   shops[i] = make_pair(a[i], b[i]);
  // }
  sort(shops.begin(), shops.end());
  //cout << shops[0].first << "a";
  int count = 0;
  unsigned long long int res = 0;
  //cout << shops[0].first << "a";
  for (int i = 0; i < n; i++){
    if(!((count + shops[i].second) > m) ){
      count += shops[i].second;
      unsigned long long int buf = 0;
        for (int j = 0; j < shops[i].second; j++) buf += shops[i].first;
      //cout << buf << "b";
      res += buf;
      //cout << res << endl;
      }
    else {
      for (int j = 0; j < (m - count); j++)  res +=  shops[i].first;
      break;
    }
  }
  //printf("%u\n", res);
  cout << res;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if A <= 5:
	print(0)
	exit()
	
print(B if A >= 13 else B//2 )

Measured memory_bytes: 5196
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    grid = [list(input()) for _ in range(H)]

    maze = [[f_inf] * W for _ in range(H)]
    maze[0][0] = 0
    que = deque([[0, 0]])
    while que:
        h, w = que.popleft()
        for dh, dw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            next_h, next_w = h + dh, w + dw
            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W or grid[next_h][next_w] == "#":
                continue
            if maze[next_h][next_w] > maze[h][w] + 1:
                maze[next_h][next_w] = maze[h][w] + 1
                que.append([next_h, next_w])

    if maze[H - 1][W - 1] == f_inf:
        print(-1)
        exit()

    mi = maze[H - 1][W - 1] + 1

    cnt = 0
    for h in range(H):
        for w in range(W):
            if grid[h][w] == "#":
                cnt += 1
    res = H * W - cnt - mi
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9520
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;


int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
n = I()
# 区間スケジューリング問題 : いくつかの区間の中から重ならないように最大で何個選べるか
# ソート + 貪欲法 で解ける
arm_pos = []
for _ in range(n):
    x, l = LI()
    arm_pos.append([x - l, x + l])
arm_pos = sorted(arm_pos, key=lambda x: x[1])  # アームの終点の位置でソート
ans = n
for i in range(n - 1):
    if arm_pos[i][1] > arm_pos[i + 1][0]:  # i のアームの終点が i + 1 のアームの始点 と重なっていた場合
        arm_pos[i + 1] = arm_pos[i]  # i + 1 のアームを取り除く
        ans -= 1
print(ans)


Measured memory_bytes: 26272
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int r;
  cin>>r;
  cout<<r*r<<endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
res=0
for i in range(n-1,-1,-1):
  if i==n-1:
    res+=b[i-1]
  elif i==0:
    res+=b[0]
  else:
    res+=b[i-1] if b[i]>b[i-1] else b[i]
print(res)

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

int main()
{
    int n;
    int a[300];
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];

    int cnt[300]={0};

    for(int i=1;i<=n;i++)
    {
        while(a[i]%2==0)
        {
            a[i]/=2;
            cnt[i]++;
        }
    }

    int ans=100;
    for(int i=1;i<=n;i++)
    {
        ans = min(ans,cnt[i]);
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	long z[102] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101};
	long y[102] = {0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,4100,4200,4300,4400,4500,4600,4700,4800,4900,5000,5100,5200,5300,5400,5500,5600,5700,5800,5900,6000,6100,6200,6300,6400,6500,6600,6700,6800,6900,7000,7100,7200,7300,7400,7500,7600,7700,7800,7900,8000,8100,8200,8300,8400,8500,8600,8700,8800,8900,9000,9100,9200,9300,9400,9500,9600,9700,9800,9900,10100};
	long x[102] = {0,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,110000,120000,130000,140000,150000,160000,170000,180000,190000,200000,210000,220000,230000,240000,250000,260000,270000,280000,290000,300000,310000,320000,330000,340000,350000,360000,370000,380000,390000,400000,410000,420000,430000,440000,450000,460000,470000,480000,490000,500000,510000,520000,530000,540000,550000,560000,570000,580000,590000,600000,610000,620000,630000,640000,650000,660000,670000,680000,690000,700000,710000,720000,730000,740000,750000,760000,770000,780000,790000,800000,810000,820000,830000,840000,850000,860000,870000,880000,890000,900000,910000,920000,930000,940000,950000,960000,970000,980000,990000,1010000};
	(a==0)?cout << z[b]:(a==1)?cout << y[b]:cout << x[b];
}

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

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

    int n;cin>>n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++)
    {
        int ia;cin>>ia;
        a[i]=make_pair(ia,i+1);
    }

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

    for(int i=0;i<n;i++)cout<<a[i].second<<" ";
    cout<<"\n";

    return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout << "debug... " << n1 << "\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
public:
    ll x, y;
};
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll n;
    cin >> n;
    ve<ld> p(n);
    rep(i, 0, n)
    {
        cin >> p[i];
    }
    ve<ld> dp(n + 1, 0); //probability of having i heads.
    dp[0] = 1;           //as no coins have been tossed as of now
    rep(i, 0, n)
    {
        rev(j, i + 2, 1)
        {
            // cout<<"j.. "<<j<<"\n";
            dp[j] = dp[j - 1] * p[i] + dp[j] * (1 - p[i]);
        }
        dp[0] *= (1 - p[i]);
        // rep (j,0,n+1)
        // {
        //     cout<<"dp.. "<<j<<" --> "<<dp[j]<<"\n";
        // }
        //dp[j] shows probabitlity of having j heads after tossing (i+1) coins
    }
    ld ans = 0;
    rep(i, 0, n + 1)
    {
        if (i > n - i)
            ans += dp[i];
    }
    cout << fixed << setprecision(15) << ans << "\n";
}


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

int main(){
    string s;
    cin >> s;
    long sum=0;
    long current = 0;
    long _max = 0;
    long rt = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == '<'){
            rt = 0;
            current++;
            sum += current;
            _max = current;
        }else{
            rt++;
            current--;
            if(current == -1){
                if(_max >= rt){
                    sum += rt - 1;
                }else{
                    sum += rt;
                }
            }
            current = 0;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 900
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b = list(map(int,ipti().split()))

    if (a + b) % 2 == 0:
        ans = (a + b) // 2
        print(ans)
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_N=2010;

int N,ans=INF,cnt=0;
string S;
vector<vector<int>> G(MAX_N);
vector<int> dist(MAX_N),vs(MAX_N),ds(MAX_N),rest(MAX_N);

void dfs(int v,int p){
    if (S[v]=='1') cnt+=dist[v],++vs[v];
    int M=-1,m=-1;
    for (auto nv:G[v]){
        if (nv==p) continue;
        dist[nv]=dist[v]+1;
        dfs(nv,v);
        vs[v]+=vs[nv],ds[v]+=vs[nv]+ds[nv];
        rest[nv]+=vs[nv];
        if (chmax(M,rest[nv])) m=nv;
    }
    if (m==-1) rest[v]=0;
    if (M>ds[v]-ds[m]-vs[m]) rest[v]=M-ds[v]+ds[m]+vs[m];
    else rest[v]=ds[v]%2;
    if (p==-1&&cnt%2==0&&rest[v]==0) chmin(ans,cnt/2);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b),G[b].push_back(a);
    }
    rep(i,N){
        cnt=0;
        dist.assign(MAX_N,0);
        vs.assign(MAX_N,0);
        ds.assign(MAX_N,0);
        dfs(i,-1);
    }
    if (ans==INF) ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<vector<char>>v;
    vector<vector<ll>>dp;
    for(ll i=0;i<n;i++){
        vector<char>z;
        vector<ll>q;
        dp.push_back(q);
        v.push_back(z);
        for(ll j=0;j<m;j++){
            char s;
            cin>>s;
            v[i].push_back(s);
            dp[i].push_back(0);
        }
    }
    dp[0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(v[i][j]=='#'){dp[i][j]=0;continue;}
            else if(v[i][j]=='.'){
                if(j>=1){
                    dp[i][j]+=dp[i][j-1];
                }
                if(i>=1){
                    dp[i][j]+=dp[i-1][j];
                }
            }
            dp[i][j]=dp[i][j]%mod;
        }
    }
    cout<<dp[n-1][m-1]<<endl;

    return 0;
    }


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

int main() {
  vector<char> c(6);
  for(int i=0;i<6;i++) {
    cin >> c[i];
  }

  bool yes = true;

  for(int i=0;i<3;i++) {
    if(c[i] != c[5-i]) {
      yes = false;
    }
  }

  if(yes) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int count = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] != t[i])
            count++;
    }
    cout << count << "\n";

    return 0;
}


Measured memory_bytes: 3744
#include <iostream>
using namespace std;
int main()
{
	int n = 0,ans = 0,max = 0,s = 0;
	cin >> n;
	for(int i = 0;i < n;i ++)
	{
		cin >> s;
		max = max > s ? max : s;
		ans += s;
	}
	if(ans > 2 * max)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
 
int main(){
	ll n;
	cin>>n;
	map<string,ll> m;
	rep(i,0,n){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
	
}
		 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
const int mod = 1000000007;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


signed main(){
    int x,y;cin >> x >> y;
    rep(a,x+1){
        int b = y-2*a;
        if(a+2*b == x){
            int ret = 1;
            int n = a+b;
            int k = a;
            for(int i = 1;i <= k;i++){
                ret = (ret*(n-i+1))%mod;
                ret = (ret*modpow(i,mod-2,mod))%mod;
            }
            cout << ret%mod << endl;
            return 0;
        }


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

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

int main() {
  int N,i,c=0;
  cin >> N;
  vector<int> p(N),q(N);
  for(i=0; i<N; i++) {
    cin >> p.at(i);
    q.at(i) = p.at(i);
  }
  sort(q.begin(), q.end());
  
  for(i=0; i<N; i++) {
    if(p.at(i) != q.at(i))
      c++;
    if(c>2)
      break;
  }
  
  if(i==N)
  	cout << "YES";
  else
    cout << "NO";
  cout << endl;
}

Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Sun Mar 22 23:25:40 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b, c, d = na()
e = min(b, d) - max(a, c)
print(0 if e < 0 else e)

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

int main()
{
	int n;
	cin>>n;
	int x[n+1];
	
	for(int i=1; i<=n; i++)	cin>>x[i];
	sort(x+1,x+n+1);
	
	int minv=0,naili=1e9;
	for(int p=x[1]; p<=x[n]; p++)
	{
		minv=0;
		for(int i=1; i<=n; i++)
		{
			minv+=(x[i]-p)*(x[i]-p);
		}
		
		if(minv<naili)
			naili=minv;
	}
	
	cout<<naili<< endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import permutations
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    P = tuple(readnums())
    Q = tuple(readnums())

    a = b = 0
    for i, v in enumerate(permutations(range(1, N + 1))):
        if v == P:
            a = i
        if v == Q:
            b = i

    print(abs(a - b))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	M := Int(s)
	if N == 1 && M == 1 {
		fmt.Println(1)
		return
	}
	if N == 1 {
		fmt.Println(M - 2)
		return
	}
	if M == 1 {
		fmt.Println(N - 2)
		return
	}

	fmt.Println((N - 2) * (M - 2))
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var cardCountDic = new Dictionary<long, long>();
            foreach (var card in ReadLongs())
            {
                if (!cardCountDic.ContainsKey(card))
                {
                    cardCountDic.Add(card, 0);
                }

                cardCountDic[card]++;
            }

            var cardValueCount = cardCountDic.Count;
            var evenCount = cardCountDic.Count(x => x.Value % 2 == 0);

            if (evenCount % 2 == 0)
            {
                // 奇数枚カードがある場合
                if (cardValueCount != evenCount)
                {
                    return cardValueCount;
                }
                if (evenCount == 2)
                {
                    return cardValueCount - 1;
                }

                return cardValueCount;
            }

            return cardValueCount - 1;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 41132
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t X = 0, N = 0;
  std::cin >> X >> N;
  std::vector<bool> P(101, false);

  for (size_t i = 0; i < N; i++) {
    uint32_t p = 0;
    std::cin >> p;
    P[p] = true;
  }

  uint32_t min_diff = -1, ans = -1;
  for (size_t i = 0; i <= 101; i++) {
    if (P[i]) continue;
    uint32_t diff = (X >= i ? X - i : i - X);
    if (diff < min_diff) {
      ans = i;
      min_diff = diff;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s,t; cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t),greater<char>());

    if(s<t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int k;
  vector<int> a(5);
  REP(i, 5) {
    cin >> a[i];
  }
  cin >> k;
  REP(i, 5) {
    REP(j, 5) {
      if(i==j) {
        continue;
      }
      if(k < (a[i] - a[j])) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256