akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) rep(j, i + 1, N) if(A[i] > A[j]) ans++;
//    cout << ans << endl;
    vector<ll> B(N);
    rep(i, N) rep(j, N) if(A[i] > A[j]) B[i]++;
//    voutput(B);
    (ans *= K) %= mod;
    ll sum = 0;
    rep(i, N) (sum += B[i]) %= mod;
//    (sum *= K) %= mod;
    ll mul = (K - 1) * K / 2 % mod;
    (ans += sum * mul) %= mod;
    
    output(ans);
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=2005;
ll dp[N][N];
ll a[N],b[N];
ll f(ll i,ll j)
{
	if(i==-1 || j==-1)
		return 1;
	ll &ans=dp[i][j];
	if(ans!=-1)
		return ans;
	ans=(f(i-1,j)+f(i,j-1)-f(i-1,j-1)+mod)%mod;
	if(a[i]==b[j])
		ans=(ans+f(i-1,j-1))%mod;
	return ans;

}
void solve()
{
	ll n,m,i,j;
	cin>>n>>m;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<m;i++)
		cin>>b[i];
	// sort(a,a+n);
	// sort(b,b+n);
	memset(dp,-1LL,sizeof dp);
	cout<<f(n-1,m-1);
	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 32000
r,c = gets.chomp.split(" ").map &:to_i

m = Array.new(r+1)
r.times { |i|
  m[i] = gets.chomp.split(" ").map &:to_i
}

m[r] = Array.new(c)
c.times { |i| m[r][i] = gets.to_i }

r.times { |i|
  n = 0
  c.times { |j|
    n += m[i][j] * m[r][j]
  }
  puts n
}

Measured memory_bytes: 9000
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{ return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{ return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define mod 1000000007


int main(void) {
  int n, k;
  scanf("%d %d", &n ,&k);

  long long int ans;
  int i, j;
  long long int combi[2001][2001];
  for (i = 0; i <= n; i++) {
    combi[i][0] = 1;
    for (j = 1; j < i; j++) {
      combi[i][j] = (combi[i - 1][j - 1] + combi[i - 1][j]) % mod;
    }
    combi[i][i] = 1;
  }
  
  for (i = 1; i <= k; i++) {
    if (n - k + 1 < i) ans = 0;
    else ans = (combi[k - 1][i - 1] * combi[n - k + 1][i]) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 31360
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e6+5;
const int mod=1e9+7;
ll fac[N],inv[N],n;string s;
ll fastmi(ll a,ll b)
{
	if(b==0)return 1;
	ll res=fastmi(a,b/2);
	res=res*res%mod;
	if(b%2)res=res*a%mod;
	return res;
}
void init()
{
	fac[0]=1;
	for(int i=1;i<=2e6;i++)fac[i]=fac[i-1]*i%mod;
	inv[(int)2e6]=fastmi(fac[(int)2e6],mod-2);inv[0]=1;
	for(int i=2e6-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
	return;
}
ll C(ll x,ll y)
{
	return fac[x]*inv[x-y]%mod*inv[y]%mod;
}
ll ans;
int main()
{
	init();
	cin>>n>>s;
	for(int i=0;i<=n;i++)
	{
		ll res=0;
		res=fastmi(26,i)*C(n+s.size()-i-1,s.size()-1)%mod*fastmi(25,n-i)%mod;
		ans=(ans+res)%mod;
	}
	cout<<ans<<"\n";
	return 0;
}

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

const int N = 100005;

int n, m, c[N], d[N], r;

int main(){
    scanf("%d%d", &n, &m);
    for(int x; n--; ){
        scanf("%d", &x);
        c[x]++;
        d[x % m]++;
    }
    r += d[0] / 2;
    for(int i = 1, j = m - 1; i <= j; i++, j--){
        if(i == j){ r += d[i] / 2; break; }
        int x = i, y = j;
        if(d[x] < d[y]) swap(x, y);
        r += d[y];
        int p = 0;
        for(int k = x; k < N; k += m) p += c[k] / 2 * 2;
        r += min(p, d[x] - d[y]) / 2;
    }
    printf("%d\n", r);
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> ret;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}
struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n) : fac(2, 1), finv(2, 1), inv(2, 1)
    {
        int i;

        rep(i, 2, n + 1)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}

ll mod_conb(ll n, ll k)
{
    ll ans = 1;

    if (n < k || n < 0 || k < 0)
    {
        return 0;
    }

    for (long long i = 0; i < k; i++)
    {
        ans *= n - i;
        ans %= MOD;
        ans *= power(i + 1, MOD - 2);
        ans %= MOD;
    }

    return ans;
}

int main(void)
{
    ll n, m;

    factorial f(1e6);

    cin >> n >> m;

    map<ll, ll> a = prime_factor(m);

    ll ans = 1;

    for (auto x : a)
    {
        ans *= f.comb(x.second + n - 1, x.second);
        ans %= MOD;
    }

    cout << ans << endl;
}



Measured memory_bytes: 24892
n = gets.to_i
 
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
ans=0

for i in 0..n-1
    ans+=b[a[i]-1]
    ans+=c[a[i]-1]if i!=n-1 && a[i]+1==a[i+1]
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: 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...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
 
char a[7][7];
char b[7][7];
ll row, col, k; 

void copy_data() {
    // trace("copy_data");
    for(int i = 0; i < row; i++) {
        for(int j = 0; j < col; j++) {
            b[i][j] = a[i][j];
        }
    }
}

void mark(int rw, int cl) {
    // trace(rw, cl);
    for(int i = 0; i < row; i++) {
        if((1 << i) & rw) {
            for(int j = 0; j < col; j++) {
                b[i][j] = '$';
            }
        }
    }

    // trace("makrk", rw, cl);
    for(int i = 0; i < col; i++) {
        if((1 << i) & cl) {
            for(int j = 0; j < row; j++) {
                b[j][i] = '$';
            }
        }
    }
}

bool check() {
    int cnt = 0;
    for(int i = 0; i < row; i++) {
        for(int j = 0; j < col; j++) {
            if(b[i][j] == '#') cnt++;
        }
    }
    return (cnt == k);
}

int main(){   
    cin >> row >> col >> k;
    for(int i = 0; i < row; i++) {
        for(int j = 0; j < col; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << row); i++) {
        for(int j = 0; j < (1 << col); j++) {
            copy_data();
            mark(i, j);
            if(check()) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 3504
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        a--;
        ans += a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
typedef unsigned  uint;
typedef unsigned long long int ull;
struct mint{
	uint v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/*mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
	}*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};
int main(){
ll n;
cin>>n;
V<ll> a(n);
for(int i=0;i<n;i++)cin>>a[i];
ll t=0;
mint ans=0,now=1;
while(61>t){
    mint z=0,o=0;
    for(int i=0;i<n;i++){
         if(a[i]&(1ll<<t))o+=1;
         else z+=1;
    }
    ans+=(z*o*now);
    now*=2;
    t++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Integer w = Integer.parseInt(scan.next());
        Integer h = Integer.parseInt(scan.next());

        List<Problem> problemList = new ArrayList<Problem>();
        while (w != 0 && h != 0) {
            int[][] sea = new int[h][w];
            for (int i = 0; i < sea.length; i++) {
                for (int j = 0; j < sea[i].length; j++) {
                    sea[i][j] = Integer.parseInt(scan.next());
                }
            }
            problemList.add(new Problem(sea));

            w = Integer.parseInt(scan.next());
            h = Integer.parseInt(scan.next());
        }
        scan.close();

        int[] answer = new int[problemList.size()];
        for (int p = 0; p < problemList.size(); p++) {
            Problem problem = problemList.get(p);
            int[][] sea = problem.sea_;
            boolean[][] done = problem.done_;
            int count = 0;

            for (int i = 0; i < sea.length; i++) {
                for (int j = 0; j < sea[0].length; j++) {
                    if (!done[i][j] && sea[i][j] == 1) {
                        count++;
                        dfs(i, j, sea, done);
                    }
                }
            }

            answer[p] = count;
        }

        for (int i : answer) {
            System.out.println(i);
        }
    }

    private static void dfs(int i, int j, int[][] sea, boolean[][] done) {
        done[i][j] = true;
        for (int dx = -1; dx <= 1; dx++) {
            for (int dy = -1; dy <= 1; dy++) {
                int ni = i + dx;
                int nj = j + dy;

                if (ni < 0 || ni >= sea.length || nj < 0 || nj >= sea[0].length) {
                    continue;
                }
                if (done[ni][nj] || sea[ni][nj] == 0) {
                    continue;
                }
                dfs(ni, nj, sea, done);
            }
        }
    }

}

class Problem {

    int[][] sea_;

    boolean[][] done_;

    public Problem(int[][] sea) {
        sea_ = sea;
        done_ = new boolean[sea.length][sea[0].length];
        for (int i = 0; i < sea.length; i++) {
            for (int j = 0; j < sea[i].length; j++) {
                done_[i][j] = false;
            }
        }
    }
}



Measured memory_bytes: 39320
#include <cstdio>
int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if(a == 1 && b != 1) printf("Alice\n");
    else if(b == 1 && a != 1) printf("Bob\n");
    else if(a > b)  printf("Alice\n");
    else if(a < b)  printf("Bob\n");
    else if(a == b) printf("Draw\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    int N;
    cin >> N;

    vector<int> P(N);
    vector<int> Q(N);

    rep(i, 0, N)
    {
        int p;
        cin >> p;
        P[i] = p;
    }
    rep(i, 0, N)
    {
        int q;
        cin >> q;
        Q[i] = q;
    }

    vector<int> v(N);
    rep(i, 0, N)
    {
        v[i] = i + 1;
    }

    int a = 0;
    int b = 0;

    int count = 1;

    do
    {
        if (equal(P.begin(), P.end(), v.begin(), v.end()))
        {
            a = count;
        }

        if (equal(Q.begin(), Q.end(), v.begin(), v.end()))
        {
            b = count;
        }

        ++count;

    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;

    return 0;
}


Measured memory_bytes: 3624
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {n:usize, d:[[usize;2];n]}

    let mut i = 0;
    let mut flag = false;
    let mut cnt = 0;
    while i < n {
        if d[i][0] == d[i][1] {
            cnt += 1;
            if cnt == 3 {
                flag = true;
            }
        } else {
            cnt = 0;
        }
        i += 1;
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2128
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
  int x=0,y=0,z=0,w=0;
std::cin >> x>>y>>z;
if(z<=x)std::cout << 0 << '\n';
else if(z>x){
  if(z<=x+y)std::cout << z-x << '\n';
  else std::cout << "NA" << '\n';
}
}




Measured memory_bytes: 3096
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    ll x[n], y[m];
    REP(i, n) {
    	cin >> x[i];
    }
    REP(i, m) {
    	cin >> y[i];
    }

    ll ans;
    // 答えになる式を因数分解し、工夫して計算するとO(n+m) となる
    ll xSum = 0;
    ll ySum = 0;
    REP(i, n) {
    	xSum += i * x[i] - (n - 1 - i) * x[i];
    }
    REP(i, m) {
    	ySum += i * y[i] - (m - 1 - i) * y[i];
    }
    xSum %= MOD;
    ySum %= MOD;
    ans = xSum * ySum;
    ans %= MOD;

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[4010][4010];
int x[200005],y[200005];
long long qpow(long long a,long long b) {
	long long ans = 1;
	while(b) {
		if(b&1LL) ans=ans*a%mod;
		b>>=1;a=a*a%mod;
	}
	return ans;
}
long long fac[8005],ifac[8005];
int main()
{
    fac[0] = 1;
	for(int i=1;i<=8000;i++) fac[i]=fac[i-1]*i%mod;
	ifac[8000]=qpow(fac[8000],mod-2);
	for(int i=8000;i>=1;i--) ifac[i-1]=ifac[i]*i%mod;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",x+i,y+i);
        dp[2005-x[i]][2005-y[i]]++;
    }
    for(int i=1;i<4010;i++)
    {
        for(int j=1;j<4010;j++)
        {
            dp[i][j]+=dp[i-1][j];
            if(dp[i][j]>=mod) dp[i][j]-=mod;
            dp[i][j]+=dp[i][j-1];
            if(dp[i][j]>=mod) dp[i][j]-=mod;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+dp[x[i]+2005][y[i]+2005]);
        if(ans>=mod) ans-=mod;
    }
    //printf("%d\n",ans);
    for(int i=1;i<=n;i++)
    {
        ans=(ans-fac[2*x[i]+2*y[i]]*ifac[2*x[i]]%mod*ifac[2*y[i]]%mod+mod)%mod;
    }
    //printf("%d\n",ans);
    ans=1LL*ans*(mod+1)/2%mod;
    printf("%d\n",ans);
    return 0;
}


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

int main() {
 int M;
 cin >> M;
  for(int i = 1; i < M+1; i++){
    int x = i*1.08;
    int y = x/1;
    if(y == M){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    ln=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
    dp=[0 for i in range(n+1)]
    dp[1] = 1
    for i in range(2,n+1):
        lnt = [ln[j] for j in range(12) if i >= ln[j]]
        tdp=[]
        for slnt in lnt:
            tdp.append(dp[i-slnt])
        dp[i]=min(tdp)+1
    return dp[-1]

print(main())

Measured memory_bytes: 44656
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int sx = in.nextInt();
        int sy = in.nextInt();
        int tx = in.nextInt();
        int ty = in.nextInt();
        int u = ty-sy;
        int r = tx-sx;
        String t = "";
        for(int i=0;i<u;i++){
            t+="U";
        }
        System.out.print(t);
        t="";
        for(int i=0;i<r;i++){
            t+="R";
        }
        System.out.print(t);
        t="";
        for(int i=0;i<u;i++){
            t+="D";
        }
        System.out.print(t);
        t="";
        for(int i=0;i<r+1;i++){
            t+="L";
        }
        System.out.print(t);
        t="";
        for(int i=0;i<u+1;i++){
            t+="U";
        }
        System.out.print(t);
        t="";
        for(int i=0;i<r+1;i++){
            t+="R";
        }
        t+="DR";
        System.out.print(t);
        t="";
        for(int i=0;i<u+1;i++) {
            t += "D";
        }
        System.out.print(t);
        t="";
        for(int i=0;i<r+1;i++){
            t+="L";
        }
        System.out.print(t+"U");

    }
}


Measured memory_bytes: 60500
import itertools,math
def isOverlapped(x1,y1,x2,y2,r1,r2):        
    return ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))**0.5<=r1+r2+0.000009
while True:
    n=input()
    if n==0:
        break
    li=[]
    for i in xrange(n):
        li.append(map(float,raw_input().split(",")))
    ma=1
    for i,j in itertools.combinations(xrange(n),2):
        if isOverlapped(li[i][0],li[i][1],li[j][0],li[j][1],1,1):
            L=((li[i][0]-li[j][0])**2+(li[i][1]-li[j][1])**2)**0.5
            t=math.atan2(li[j][1]-li[i][1],li[j][0]-li[i][0])
            al=math.acos(L/2)
            node=[[li[i][0]+math.cos(t+al),li[i][1]+math.sin(t+al)],
                  [li[i][0]+math.cos(t-al),li[i][1]+math.sin(t-al)]]
            for p in xrange(2):
                c=0
                for q in xrange(n):
                    if isOverlapped(node[p][0],node[p][1],li[q][0],li[q][1],0,1):
                        c+=1
                ma=max(c,ma)
    print ma

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
//test
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long n,sum=0;
    cin>>n;
    
    vector<long long> costs(n);
    for(int i=0;i<n;i++){
        cin>>costs[i];
    }
    
    sort(costs.begin(),costs.end(),greater<int>());
    
    long long cal=1,ft=1,tol=1;
    for(int i=0;i<n;i++){
        cal=(cal*2)%1000000007;
        if(i<n-1) ft=cal;
        if(i<n-2) tol=cal;
    }
    
    for(int i=0;i<n;i++){
        sum=(sum+ft*costs[i])%1000000007;
        ft=(ft+tol)%1000000007;
    }
    
    cout<<(sum*cal)%1000000007<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    cout << " ";
    cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
}


Measured memory_bytes: 3084
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(b-a <= 0)cout << "delicious" << endl;
    else if(b-a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
        #define ll  long long
        #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define rep(i,a,b)  for(ll i=a;i<b;i++)
        #define pb push_back
        #define Max(x,y,z) max(x,max(y,z))
        #define f first
        #define s second
        #define lbd lower_bound
        #define sz(x)       (ll)x.size()
        #define pi 3.1415926536
        #define mod 1000000007
        #define MOD 998244353
        using namespace std;
        const int N=100000;
        void solve()
        {
            ll n,m,k,res=0,l=0,r=0,z,sum1=0,cnt1=0,h,res1,a,b,c,d,x,y;
            ll W;
            cin>>n>>W;
            vector<pair<ll,ll>> v(n);
            ll sum=0;
            rep(i,0,n)
                {cin>>v[i].f>>v[i].s; sum+=v[i].s;}
            ll cnt[n+1][sum+1];
            rep(i,0,sum+1) cnt[0][i]=INT_MAX;
            for(ll i=0;i<=n;i++) cnt[i][0]=0;
            rep(i,1,n+1)
            {
                rep(j,1,sum+1)
                {
                    cnt[i][j]=cnt[i-1][j];
                    if(j>=v[i-1].s)
                        cnt[i][j]=min(cnt[i][j],cnt[i-1][j-v[i-1].s]+v[i-1].f);
                }
                //cout<<"\n";
            }
            ll ans=0;
            rep(i,0,sum+1)
            {
                if(ans<i && cnt[n][i]<=W)
                    ans=i;
            }
            cout<<ans;     
            
        
     
    }
        int main()
        {   
           /* #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
            #endif*/
     
            speed_up
            ll t;
            //cin>>t;
            t=1;
            while(t--)
                solve();
        }

Measured memory_bytes: 79232
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int a = 0;
        
        while(N>0)
        {
            N -= 1000;
        }
        a = N * -1;
        Console.WriteLine(a);
    }

}

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

string s[1010];
int main() {
	while(true) {
		int n, m;
		cin >> n >> m;
		if(!n && !m) break;
		pair<int, int> ma[1010];
		for(int i=0; i<n; ++i) {
			cin >> s[i];
			int a, b;
			cin >> a >> b;
			ma[i] = {b-a+1, b};
		}
		for(int i=0; i<m; ++i) {
			int a;
			cin >> a;
			bool flag = true;
			for(int j=0; j<n; ++j) {
				if(ma[j].first <= a && a <= ma[j].second) {
					flag = false;
					cout << s[j] << " " << a-ma[j].first+1 << endl;
					break;
				}
			}
			if(flag) {
				cout << "Unknown" << endl;
			}
		}
	}
}
		

Measured memory_bytes: 3160
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + y1 - y2
y3 = y2 - x1 + x2
x4 = x3 + x1 - x2
y4 = y3 + y1 - y2

print(x3, y3, x4, y4)



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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
   for (int i = 0; i < B - A + 1; i++) {
     int x = A + i;
     if (x <= A + K -1 || x >= B - K + 1)
       cout << x << endl;
   }
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//using ll=long long;
const double EPS = 1e-10;
inline bool equals(double a, double b) { return fabs(a - b) < EPS; }
const double PI = 3.141592653589793238;
class Point {
public:
	double x, y;
	Point(double x, double y) :x(x), y(y) {}
	Point() {}
	Point operator +(const Point &p) const{ return Point(x + p.x, y + p.y); };
	Point operator -(const Point &p) const{ return Point(x - p.x, y - p.y); }
	Point operator *(double k) { return Point(x*k, y*k); }
	Point operator /(double k) { return Point(x / k, y / k); }
};

using Vector = Point;
inline double norm(Vector a) {
	return a.x*a.x + a.y*a.y;
}
double absv(Vector a) {
	return sqrt(norm(a));
}
inline double dot(Vector a, Vector b) {
	return a.x*b.x + a.y*b.y;
}
inline double cross(Vector a, Vector b) {
	return a.x*b.y - a.y*b.x;
}
struct Segment {
	Point p1, p2;
};

using Line = Segment;
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
using Polygon = vector<Point>; 
Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base*r;
}
Point reflect(Segment s, Point p) {
	return p + (project(s, p) - p)*2.0;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (norm(a) < norm(b)) return ONLINE_FRONT;
	return ON_SEGMENT;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 and ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
double getDistance(Point a, Point b) {
	return absv(a - b);
}

double getDistanceLP(Line l, Point p) {
	return abs(cross(l.p2 - l.p1, p - l.p1) / absv(l.p2 - l.p1));
}

double getDistanceSP(Segment s, Point p) {
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return absv(p - s.p1);
	if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return absv(p - s.p2);
	return getDistanceLP(s, p);
}

double getDistance(Segment s1,Segment s2){
	if (intersect(s1, s2)) return 0.0;
	return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)), min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}
int main() {
	int q, x[4], y[4];
	Point p[4];
	cin >> q;
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> x[j] >> y[j];
			p[j] = Point(x[j], y[j]);
		}
		Segment s[2];
		s[0] = { p[0],p[1] }, s[1] = { p[2],p[3] };
		printf("%.10lf\n", getDistance(s[0], s[1]));
	}
}

Measured memory_bytes: 3204
#include <stdio.h>
int main(void){
    int x, y;
    
    scanf("%d %d", &x, &y);
    
    if (x == 2 && y == 2) {
        printf("Yes\n");
    }
    else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
        printf("Yes\n");
    }
    else if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[1005][1 << 12];

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;

  vector<int> price(m);
  vector<int> box_bits(m);
  rep(i, 0, m) {
    int c;
    cin >> price[i] >> c;
    rep(j, 0, c) {
      int b;
      cin >> b;
      box_bits[i] |= (1 << (b - 1));
    }
  }

  Fill(dp, LL_INF);
  dp[0][0] = 0;
  rep(i, 0, m) rep(j, 0, (1 << n)) {
    if (dp[i][j] == LL_INF) continue;
    chmin(dp[i + 1][j], dp[i][j]);
    chmin(dp[i + 1][j | box_bits[i]], dp[i][j] + price[i]);
  }

  put(dp[m][(1 << n) - 1] == LL_INF ? -1 : dp[m][(1 << n) - 1]);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 32384
#include <iostream>


int main() {
    int k, n;
    std::cin >> k >> n;

    int pos_min;
    std::cin >> pos_min;
    int pos_last = pos_min;
    int max_span = 0;
    for (int i = 1; i < n; i++) {
        int pos;
        std::cin >> pos;
        max_span = std::max(max_span, pos - pos_last);
        pos_last = pos;
    }

    int span = k - pos_last + pos_min;
    max_span = std::max(span, max_span);
    std::cout << k - max_span << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <climits>
#include <cfloat>
#include <algorithm>
using namespace std;

class Edge
{
public:
    int to, cap, rev;
    Edge(){};
    Edge(int to0, int cap0){to = to0; cap = cap0;}
    Edge(int to0, int cap0, int rev0){to = to0; cap = cap0; rev = rev0;}
};

int n;
vector<vector<Edge> > edges;
vector<bool> used;

int dfs(int s, int t, int f){
    if(s == t)
        return f;
	used[s] = true;
    for(unsigned i=0; i<edges[s].size(); ++i){
        Edge& e = edges[s][i];
        if(!used[e.to] && e.cap > 0){
            int g = dfs(e.to, t, min(f, e.cap));
            if(g > 0){
                e.cap -= g;
                edges[e.to][e.rev].cap += g;
                return g;
            }
        }
    }
    return 0;
}

int flow(int s, int t, int f){
	used.assign(n+1, false);
	return dfs(s, t, f);
}

int main()
{
	int e, q;
	cin >> n >> e >> q;

	edges.assign(n+1, vector<Edge>());
	for(int i=0; i<e; ++i){
		int f, t;
		cin >> f >> t;
		edges[f].push_back(Edge(t, 1, edges[t].size()));
		edges[t].push_back(Edge(f, 1, edges[f].size()-1));
	}

	int ret = 0;
	for(;;){
		int f = flow(1, n, INT_MAX);
		if(f == 0)
			break;
		ret += f;
	}

	for(int i=0; i<q; ++i){
		int m, a, b;
		cin >> m >> a >> b;
		if(m == 1){
			unsigned j = 0;
			while(j < edges[a].size() && edges[a][j].to != b)
				++ j;
			if(j < edges[a].size()){
				edges[a][j].cap = 1;
				edges[b][edges[a][j].rev].cap = 1;
			}else{
				edges[a].push_back(Edge(b, 1, edges[b].size()));
				edges[b].push_back(Edge(a, 1, edges[a].size()-1));
			}
			ret += flow(1, n, 1);
		}else{
			unsigned j = 0;
			while(edges[a][j].to != b)
				++ j;
            if(edges[a][j].cap == 1){
				edges[a][j].cap = 0;
				edges[b][edges[a][j].rev].cap = 0;
            }else{
                if(edges[a][j].cap != 0){
                    j = edges[a][j].rev;
                    swap(a, b);
                }
				edges[b][edges[a][j].rev].cap = 0;
                if(flow(a, b, 1) == 0){
				    flow(a, 1, 1);
				    flow(n, b, 1);
			        -- ret;
			        ret += flow(1, n, 1);
                }
            }
		}
		cout << ret << endl;
	}

	return 0;
}

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

int main(void) {
    vector<int> v;
    int a, b;
    cin >> a >> b;
    v.push_back(a + b);
    v.push_back(a - b);
    v.push_back(a * b);
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#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 fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int A, B; cin >> A >> B;
    if ((A + B) % 2 == 0) cout << (A + B) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int, input().split())
ans = float('inf')
for i in range(0,max(X,Y)*2+1,2):
    s = 0
    x = X-i//2
    y = Y-i//2
    if x >= 1:
        s += x*A 
    if y >= 1:
        s += y*B
    s += i*C
    ans = min(ans, s)
print(ans)

Measured memory_bytes: 39280
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <limits>
#include <map>
using namespace std;

int main()
{
    int a, b;
    char op;
    while (cin >> a >> op >> b)
    {
        int result;
        if (op == '+') {
            result = a + b;
        } else if (op == '-') {
            result = a - b;
        } else if (op == '*') {
            result = a * b;
        } else if (op == '/') {
            result = a / b;
        } else if (op == '?') {
            break;
        }
        cout << result << endl;
    }

    return 0;
}


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

int main(){
    int a[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    int k;
    cin>>k;
    if((a[4]-a[0])<=k){
        cout<<"Yay!";
    }
    else{
        cout<<":(";
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
if n > 999:
    print("ABD")
else:
    print("ABC")


Measured memory_bytes: 3692
n, W = map(int, input().split())
w1, w2, w3, w4 = [], [], [], []
w, v = map(int, input().split())
w1.append(v)

# 4パターンしかない
for _ in range(n-1):
    a, b = map(int, input().split())
    if a == w:
        w1.append(b)
    if a == w+1:
        w2.append(b)
    if a == w+2:
        w3.append(b)
    if a == w+3:
        w4.append(b)
        
# 降順にする
for w_ in [w1, w2, w3, w4]:
    w_.sort(reverse= True)
    
ans = 0
for i in range(0, len(w1)+1):
    for j in range(0, len(w2)+1):
        for k in range(0, len(w3)+1):
            # w4を詰める前にチェック
            res = W - (i * w + j * (w+1) + k * (w+2))
            if res < 0:
                continue
            # w4は詰めれるだけ詰める
            tmp = sum(w1[:i])+sum(w2[:j])+sum(w3[:k])+sum(w4[:res//(w+3)])
            ans = max(tmp, ans)
            
print(ans)

Measured memory_bytes: 45400
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 2020
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,K,a[MAX];
int mn[MAX];
ll ans=1e18;
int main()
{
	n=read();K=read();memset(mn,63,sizeof(mn));
	for(int i=0;i<n;++i)a[i]=read();
	for(int i=0;i<=n;++i)
	{
		for(int j=0;j<n;++j)
			mn[j]=min(mn[j],a[(j-i+n)%n]);
		ll ret=0;
		for(int j=0;j<n;++j)ret+=mn[j];
		ans=min(ans,ret+1ll*K*i);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long q,h,s,d,n,ans;
  cin >> q >> h >> s >> d;
  cin >> n;
  long long a=min(4*q,2*h);
  long long b=min(a,s); //1㍑の最安値
  long long c=min(2*b,d); //2㍑の最安値
  ans=(n/2)*c+(n%2)*b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H, A;
    cin >> H >> A ;
    for(int i=0 ; i <=10000 ; i++){
        if(H>0){
        H = H - A;
        }
        else{
            cout << i;
            break;
        }
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;

  int cnt = 0;
  bool wrong = false; // ????????????true????????¨?????????

  string s;
  rep (i, n) {
    cin >> s;
    if (s == "A") {
      cnt++;
    }
    else if (s == "Un") {
      if (cnt > 0) {
        cnt--;
      }
      else {
        wrong = true;
      }
    }
  }

  if (wrong || cnt > 0) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }

  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,temp;
    cin>>a>>b>>c;
    int max=a;
    max>=b ? max=max : max=b;
    max>=c ? max=max : max=c;
    temp=(a+b+c)-max;
    cout<<temp;
    return 0;
}


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

const int MAXN=1e5+10;
vector<int> v[MAXN];
vector<int> st1, st2;
bool flag=false;
int vis[MAXN];

void dfs(int point){
    if(flag){
        return;
    }
    for(int i=0; i<v[point].size(); i++){
        int cnt=v[point][i];
        if(vis[point]==vis[cnt]){
            flag=true;
            return;
        }else if(!vis[cnt]){
            if(vis[point]==1){
                vis[cnt]=2;
                st2.push_back(cnt);
                dfs(cnt);
            }else if(vis[point]==2){
                vis[cnt]=1;
                st1.push_back(cnt);
                dfs(cnt);
            }
        }
    }
}

int main(void){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, x, y;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=1; i<=n; i++){
        if(v[i].size()==0){
            continue;
        }else if(!vis[i]){
            vis[i]=1;
            st1.push_back(i);
            dfs(i);
        }
    }
    ll cnt;
    if(flag) cnt = (ll)n * (n - 1) / 2 - m;
    else cnt = (ll)st1.size() * st2.size() - m;
    cout << cnt << endl;
    return 0;
}

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

int main(){
  int h, w;

  while(true){
    cin >> h >> w;
    if( h + w == 0 ){ break; }

    for( int i = 0; i < h; i++){
      for( int j = 0; j < w; j++){
        if( i > 0 && i < h - 1 && j > 0 && j < w - 1){ cout << "."; }
        else{ cout << "#"; }
      }
      cout << "\n";
    }
    cout << "\n";
  }

  return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) cout << s << endl;
  else{
    rep(i,k) cout << s.at(i);
    cout << "..." <<  endl;
  }
  return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define ppb pop_back

using namespace std;
template<typename T> using vec = vector<T>;
using ll = long long;

int main(int argc,char* argv[])
{
    int N,K;
    cin>>N>>K;
    vec<int> count(N);

    int i = 0;
    rep(j, N)
    {
        while (K > pow(2,i) * (j+1))
            i++;
        count[j] = i;
        i=0;
    }

    double sum = 0;
    rep(i,N){
        sum+=1.0/N*pow(1/2.0,count[i]);
    }
    cout<<setprecision(12)<<sum<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
ll a[200010];ll qz[200010],ret;
int main(){
	n=r;m=r;ret=10000000000000000ll;
	for(rt i=1;i<=n;i++)a[i]=r,qz[i]=qz[i-1]+a[i];
	for(rt i=n;i>=1;i--){
		ll now=(ll)m*i;
		for(rt j=1,R=n;R;j++){
			int L=max(1,R-i+1);
			now+=(qz[R]-qz[L-1])*max(j*2+1,5);
			if(now>ret)break;
			R=L-1;
		}
		ret=min(ret,now);
	}
	cout<<ret+1ll*n*m;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    if( N % 10 == (N / 10) % 10 && (N / 10) % 10 == (N / 100) % 10)
        cout << "Yes" << endl;
      
    else if( (N / 10) % 10 == (N / 100) % 10 && (N / 100) % 10 == N / 1000)
        cout << "Yes" << endl;
    
    else
        cout << "No" << endl;
    
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, n):
        self.bit = [0]*(n+1)
    
    def sumB(self, i):
        s = 0
        while(i>0):
            s+=self.bit[i]
            i -= i & -i
        return s
    
    def addB(self, i, x):
        while(i < len(self.bit)):
            self.bit[i] += x
            i += i & -i
            
n = int(input())
A = [(i+1,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
b = BIT(n)
for i in range(n):b.addB(i+1,1)
ans=0
for i,j in A:
    ans+=b.sumB(i)
    b.addB(i,-1)
print(ans-n)


Measured memory_bytes: 47808
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){

    int C[3][3],A[3],B[3];
    bool flag=0;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> C[i][j];
        }
    }

    A[0]=0;
    B[0]=C[0][0];
    B[1]=C[0][1];
    B[2]=C[0][2];
    A[1]=C[1][0]-B[0];
    A[2]=C[2][0]-B[0];

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

            if((A[i]+B[j])!=C[i][j]){
                flag = 1;
            }
            
        }
    }

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

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////
int r,c,n;
int edge(int x,int y){
    int res=-1;
    if(y==0){
        res=x;
    }else if(x==r){
        res=r+y;
    }else if(y==c){
        res=r+c+r-x;
    }else if(x==0){
        res=2*r+2*c-y;
    }
    return res;
}

int main(){
    cin>>r>>c>>n;
    vector<i_i>v;
    for(int i=1;i<=n;i++){
        int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
        int e1=edge(x1,y1),e2=edge(x2,y2);
        if(e1!=-1&&e2!=-1){
            v.pb(i_i(e1,i));
            v.pb(i_i(e2,i));
        }
    }
    sort(v.begin(),v.end());
    //for(auto x:v){cout<<x.first<<" "<<x.second<<endl;}
    
    stack<int>s;
    for(auto y:v){
        int x=y.second;
        if(s.empty()){
            s.push(x);
        }else if(s.top()==x){
            s.pop();
        }else{
            s.push(x);
        }
    }
    if(s.empty())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}

Measured memory_bytes: 2420