akhauriyash/Code-Regression huggingface dataset:
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  1/21 20:04:42 2018
 * Ended  Time*  : 日  1/21 20:08:52 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

const int MaxN = 1e5;
int n;
int t[MaxN + 5], x[MaxN + 5], y[MaxN + 5];

int main()
{
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++)
			scanf("%d %d %d", &t[i], &x[i], &y[i]);
		bool flag = true;
		for(int i = 1; i <= n; i++){
			int len = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
			int tim = t[i] - t[i-1];
			if(tim < len) flag = false;
			else if((tim%2) + (len%2) == 1) flag = false;
		}
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}


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

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if( x/d >= k ) {
        cout << x - k*d << endl;
        return 0;
    }
    if((k - (x/d))%2 == 0) cout << x%d << endl;
    else cout << abs(x%d - d) << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
 int sx , sy ,tx ,ty;
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  
  int X = tx -sx, Y = ty - sy;
  
  for(int i = 0;i < X;i ++){
    putchar('R');
  }
  for(int i = 0;i < Y;i ++){
    putchar('U');
  }
  for(int i = 0;i < X;i ++){
    putchar('L');
  }
  for(int i = 0;i < Y;i ++){
    putchar('D');
  }
  //一往復//
  putchar('D');
  for(int i = 0;i < X+1;i ++){
    putchar('R');
  }
  for(int i = 0;i < Y+1;i ++){
    putchar('U');
  }
  putchar('L');
  putchar('U');
  for(int i = 0;i < X+1;i ++){
    putchar('L');
  }
  for(int i = 0;i < Y+1;i ++){
    putchar('D');
  }
  putchar('R');
  
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int a=0;
  for(int i=0;i<s.size();i++){
    a+=s[i]-'0';
  }
  if(a%9) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3748
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
#include<algorithm>

using namespace std;

int main()
{
  long long int a;
  long double b,ans = 0;
  cin >> a >> b;
  ans = (long double)a * b;
  cout << (long long int)ans;
  return 0;  
}

Measured memory_bytes: 3732
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int INF = 0x3f3f3f3f;
int mod = 1e9+7;
int MAXN = 12345;
double eps = 1e-7;

int dcmp(double a, double b) 
{
    return (a - b < eps)? -1: (a - b >= eps);
}

bool et[22];
int ord[22];
int b[22],c[22];

bool eatall(int ord)
{
    for (int i = 1; i < ord; ++i)
        if(!et[i]) return false;
    return true;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    int n, m;

    scanf("%d", &n);

    for (int i = 0; i < n; ++i) scanf("%d", &ord[i]);

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

    for (int i = 0; i < n-1; ++i) 
    {
        scanf("%d", &c[i]);
    }

    memset(et, 0, sizeof(et));
    for (int i = 0; i < n; ++i)
    {
        if (i && ord[i-1] == ord[i]-1) 
        {
            ans += c[ord[i]-2];
        }
        et[ord[i]] = 1;
    }

    printf("%d", ans);

    return 0;
}


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

int n,a,ans;

int main(){
    while(cin>>n){
        ans = 0;
        for(int i=0; i<n; i++){
            cin>>a;
            while(a%2==0){
                a /= 2;
                ans++;
            }

        }

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


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

int main(){
    char s[200001];
    scanf("%s", s);

    int i, count = 0;
    for(i = strlen(s) - 1; s[i] != 'Z'; i--){
        count++;
    }
    for(i = 0; s[i] != 'A'; i++){
        count++;
    }

    printf("%llu\n", strlen(s) - count);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

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

  if(a+b == c || b+c == a || c+a == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (1e9 + 7)

int main(void){
    ll S, W;
    cin >> S >> W;
    if(W>=S){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
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;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll H,W,K;
    cin>>H>>W>>K;
    char C[H][W];
    int black=0;
    rep(i,0,H)
        rep(j,0,W){
            cin>>C[i][j];
            if(C[i][j]=='#')black++;
        }
    /*vi c(W,0),r(H,0);
    rep(i,0,W){
        int cnt=0;
        rep(j,0,H){
            if(C[i][j]=='#')cnt++;
        }
        c[i]=cnt;
    }
    rep(i,0,H){
        int cnt=0;
        rep(j,0,W){
            if(C[i][j]=='#')cnt++;
        }
    }*/
    ll ans=0;
    rep(i,0,1<<H){
        rep(j,0,1<<W){
            int minus=0;
            rep(wi,0,H){
                rep(wj,0,W){
                    if(((i>>wi)&1)||((j>>wj)&1)){
                        if(C[wi][wj]=='#')minus++;
                    }
                }
            }
            if(black-minus==K)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}




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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) cin >> c[i];

  int ans = 0;
  rep(si,1<<h) rep(sj,1<<w) {
    int cnt = 0;
    rep(i,h) {
      rep(j,w) {
        if (si>>i & 1) continue;
        if (sj>>j & 1) continue;
        if (c[i][j] == '#') ++cnt;
      }
    }
    if (cnt == k) ++ans;
  }
  cout << ans << endl;
}

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

int main()
{
  int H,W,h,w;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  int X=100000;
  if(H%h!=0){
    puts("Yes");
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	printf("%d ",i%h==0?X:i%h==h-1?-X-1:0);
      }
      putchar('\n');
    }
  }
  else if(W%w!=0){
    puts("Yes");
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	printf("%d ",j%w==0?X:j%w==w-1?-X-1:0);
      }
      putchar('\n');
    }
  }
  else{
    puts("No");
  }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n, x , t;
    cin >> n>>x>>t;
    int cnt = n / x;
    if (n % x != 0) {
        ++cnt;
    }
    cout << cnt*t << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3596
/*
[abc127] F - Absolute Minima
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int NONE = 1e9 + 1;
const int MAX_Q = 2e5;
const int MAX_BIT_IDX = MAX_Q;

template <typename T>
class BIT {
public:
    T b[MAX_BIT_IDX + 1];
    int n;
    void init(int num);
    T sum(int i);          // i : [0, n), returns sum of [0, i)
    void add(int i, T x);  // i : [0, n)
};

template <typename T>
void BIT<T>::init(int num) {
    n = num;
    for (int i = 0; i <= n; i++) {
        b[i] = 0;
    }
    return;
}

template <typename T>
T BIT<T>::sum(int i) {
    T s = 0;

    for (; i > 0; i -= i & -i) {
        s += b[i];
    }
    return s;
}

template <typename T>
void BIT<T>::add(int i, T x) {
    for (i += 1; i <= n; i += i & -i) {
        b[i] += x;
    }
    return;
}

int Q;
bool ty[MAX_Q];
int a[MAX_Q], b[MAX_Q];
BIT<ll> bit1, bit2;

void solve() {
    vector<int> ca(Q);
    for (int i = 0; i < Q; i++) {
        ca[i] = a[i];
    }
    sort(ca.begin(), ca.end());
    ca.erase(unique(ca.begin(), ca.end()), ca.end());
    for (int i = 0; i < Q; i++) {
        if (a[i] != NONE) {
            a[i] = lower_bound(ca.begin(), ca.end(), a[i]) - ca.begin();
        }
    }

    bit1.init(Q);
    bit2.init(Q);
    int cnt = 0;
    ll sb = 0;
    for (int i = 0; i < Q; i++) {
        if (ty[i]) {
            // answer
            int ng = -1;
            int ok = Q + 1;
            while (ok - ng > 1) {
                int m = (ok + ng) / 2;
                if (bit1.sum(m + 1) >= (cnt + 1) / 2) {
                    ok = m;
                } else {
                    ng = m;
                }
            }

            int x = ca[ok];
            ll cnt_x = bit1.sum(ok) - (bit1.sum(Q) - bit1.sum(ok));
            ll sa = -bit2.sum(ok) + (bit2.sum(Q) - bit2.sum(ok));
            ll fx = sb + 1LL * x * cnt_x + sa;
            cerr << "cnt_x: " << cnt_x << endl;
            cerr << "sa: " << sa << endl;
            cout << x << " " << fx << endl;
        } else {
            // update
            cnt++;
            bit1.add(a[i], 1);
            bit2.add(a[i], ca[a[i]]);
            sb += b[i];
        }
    }
}

int main() {
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int tmp_ty;
        cin >> tmp_ty;
        ty[i] = (tmp_ty == 2);
        if (ty[i]) {
            a[i] = b[i] = NONE;
        } else {
            cin >> a[i] >> b[i];
        }
    }
    solve();

    return 0;
}


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

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

class a1 {
public:
    ll rev(ll n){
        ll res=0;
        while(n) res*=10, res+=n%10, n/=10;
        return res;
    }

	void solve(std::istream& in, std::ostream& out) {
        ll n; in>>n;
        ll counter=0;
        int digits=-1;
        ll temp=n;
        while(temp) digits++, temp/=10;
        ll limit = pow(2, digits);
        ll res=0;
        for(ll i; i<limit; ++i){
            counter=i;
            temp = n;
            while(1){
                if(counter==0){
                    res+=temp;
                    break;
                }
                ll n1=temp%10; temp/=10;
                while(counter && counter%2==0) n1*=10, n1+=temp%10, temp/=10, counter>>=1;
                res+=rev(n1);
                counter>>=1;
            }
        }
        out<<res;


	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	a1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<sstream>


using namespace std;

int main() {
	string y; string m; bool r = false; bool b = false;
	string s; cin >> s;
	string ppp(1,s[0]); string qqq(1,s[1]);
	
	y = ppp + qqq;
	string ooo(1, s[2]); string ppe(1, s[3]);
	
	m = ooo + ppe;
	
	int p ;
	int q ;
	
	stringstream iss(y);
	iss >> p;
	stringstream isy(m);
	isy >> q;
	
	if (p > 12) {
		r = true;
	}
	if (q > 12) {
		b = true;
	}
	if (q == 0) {
		b = true;
	}
	if (p == 0) {
		r = true;
	}
	

	if (r&&b) {
		cout << "NA";
	}
	else if (r) {
		cout << "YYMM";
	}
	else if (b) {
		cout << "MMYY";
	}
	else {
		cout << "AMBIGUOUS";
	}
	


}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll x;
    cin >> x;
    x ^= 1;
    cout<<x;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 3560
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        k = bisect.bisect_left(l,l[i]+l[j])
        if k > j:
            ans += k - j - 1
print(ans)

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int);
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fastpow(ll, ll, ll);
ll slowpow(ll, ll, ll);
ll _gcd(ll, ll);
ll _lcm(ll, ll);
ll extgcd(ll, ll, ll&, ll&);
ll _inv(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

int main()
{
    string s = ss(10);
    if (s == "Sunny")
        ps("Cloudy");
    else if (s == "Cloudy")
        ps("Rainy");
    else
        ps("Sunny");

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fastpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slowpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll _gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

ll _lcm(ll a, ll b)
{
    return a / _gcd(a, b) * b;
}

ll extgcd(ll a, ll b, ll& k, ll& l)
{
    if (b == 0)
    {
        k = 1; l = 0;
        return a;
    }
    ll res = extgcd(b, a % b, l, k);
    l -= a / b * k;
    return res;
}

ll _inv(ll a, ll p)
{
    return fastpow(a, p - 2, p);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 85;
int A[MAX_HW][MAX_HW],B[MAX_HW][MAX_HW];
bool dp[MAX_HW][MAX_HW][13000];

int main()
{
	int H,W;
	cin >> H >> W;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> A[i][j];
		}
	}
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> B[i][j];
		}
	}
	dp[0][0][abs(A[0][0]-B[0][0])] = true;
	rep(i,H)
	{
		rep(j,W)
		{
			rep(k,13000)
			{
				if (dp[i][j][k])
				{
					dp[i+1][j][k+abs(A[i+1][j]-B[i+1][j])] = true;
					dp[i+1][j][abs(k-abs(A[i+1][j]-B[i+1][j]))] = true;
					dp[i][j+1][k+abs(A[i][j+1]-B[i][j+1])] = true;
					dp[i][j+1][abs(k-abs(A[i][j+1]-B[i][j+1]))] = true;
				}
			}
		}
	}
	rep(i,13000)
	{
		if (dp[H-1][W-1][i])
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
using vi = vector<int>;

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
const char B = '#', W = '.';


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int H, W; in(H); in(W);

  char A[H][W];
  rep(i, H) rep(j, W)
    in(A[i][j]);

  vi white_column;
  rep(j, W) {
    bool is_white = true;
    rep(i, H) {
      if (A[i][j] == B)
        is_white = false;
    }
    if (is_white)
      white_column.push_back(j);
  }
  rep(i, H) {
    bool is_white = true;
    rep(j, W) {
      if (A[i][j] == B)
        is_white = false;
    }
    if (is_white)
      continue;
    rep(j, W) {
      if (binary_search(all(white_column), j))
        continue;
      cout << A[i][j];
    }
    cout << "\n";
  }

  return 0;
}


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

const int MAX = 2e5 + 111;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s.size() >= 4 && s.substr(0, 4) == "YAKI")
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

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

int main()
{
	string s;
	int count=0;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1')count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

use std::collections::VecDeque;

fn main() {
    input!{
        k: i64,
    }
    let mut queue = VecDeque::new();
    for i in 1..10 {
        queue.push_back(i);
    }
    let mut count: i64 = 0;
    let mut lun: i64 = 0;
    while count < k {
        count = count + 1;
        lun = queue.pop_front().unwrap();
//        println!("{}", lun);
        if lun % 10 == 0 {
            queue.push_back(10 * lun);
            queue.push_back(10 * lun + 1);
        }
        else if lun % 10 == 9 {
            queue.push_back(10 * lun + lun % 10 - 1);
            queue.push_back(10 * lun + lun % 10);
        }
        else {
            queue.push_back(10 * lun + lun % 10 - 1);
            queue.push_back(10 * lun + lun % 10);
            queue.push_back(10 * lun + lun % 10 + 1);
        }
    }
    println!("{}", lun);
}


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

int main(){
  int n,count;
  char ch[201];

  while(cin>>n){
    if(n==0)break;
    n=2*n;
    count=0;
    for(int i=0;i<n;i++)
      cin>>ch[i];

    for(int i=0;i+3<n;i+=4)
      if(ch[i]!=ch[i+2])count++;
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void){
  int x, y;
  scanf("%d%d", &x, &y);
  if (x%3 == 0){
    printf("Possible\n");
  }else if (y%3 == 0){
    printf("Possible\n");
  }else if ((x+y)%3 == 0){
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N, M;
	std::cin >> N >> M;

	ll ans = 0;
	vll p(N);
	rep(i, 0, N) {
		std::cin >> p[i];
		p[i]--;
		ans += i == p[i];
	}

	vll t(N, -1);
	map<ll, vll> dic;
	rep(i, 0, M) {
		ll x, y;
		std::cin >> x >> y;
		x--; y--;
		if (t[x] < 0 && t[y] < 0) {
			t[x] = x;
			t[y] = x;
			dic[x].push_back(x);
			dic[x].push_back(y);
		}
		else if (t[y] < 0) {
			t[y] = t[x];
			dic[t[x]].push_back(y);
		}
		else if (t[x] < 0) {
			t[x] = t[y];
			dic[t[y]].push_back(x);
		}
		else if(t[x]!=t[y]) {
			if (dic[t[x]].size() < dic[t[y]].size()) {
				swap(x, y);
			}

			ll tmp = t[y];
			for (auto a : dic[tmp]) {
				dic[t[x]].push_back(a);
				t[a] = t[x];
			}
			dic[tmp].clear();
		}
	}

	for (auto a : dic) {
		for (auto b : a.second) {
			if (b != p[b]) {
				if (t[p[b]] == a.first) {
					ans++;
				}
			}
		}
	}

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


Measured memory_bytes: 15944
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

w,h,x,y=map(int, input().split())

area = float((w * h) / 2)
print(area)

if ((w / 2) == x) and ((h / 2) == y):
    print(1)
else:
    print(0)

Measured memory_bytes: 21500
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

const int N = 100010;
const int MOD = (int)1e9 + 7;
int n, a[N];

ll bin_exp (ll a, ll b) {
	if (b == 0) return 1;
	if (b & 1) return (a * bin_exp(a, b - 1)) % MOD;
	ll res = bin_exp(a, b / 2);
	return (res * res) % MOD;
}

bool possible () {
	if (n & 1) {
		if (a[0] != 0) return false;
		for (int i = 1; i < n; i += 2) {
			if (a[i] != i + 1 || a[i + 1] != i + 1) 
				return false;
		}
		return true;
	}
	else {
		for (int i = 0; i < n; i += 2) {
			if (a[i] != i + 1 || a[i + 1] != i + 1)
				return false;
		}
		return true;
	}
}

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	if (possible()) printf("%lld\n", bin_exp(2, n/2));
	else printf("0\n");
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[][][] kousya=new int[4][3][10];
    for(int i=0;i<n;i++){
      int b=Integer.parseInt(scan.next());
      int f=Integer.parseInt(scan.next());
      int r=Integer.parseInt(scan.next());
      int v=Integer.parseInt(scan.next());

      switch(b){
        case 1:
            if(kousya[b-1][f-1][r-1]<10){
              kousya[b-1][f-1][r-1]+=v;
            }
            break;
        case 2:
            if(kousya[b-1][f-1][r-1]<10){
              kousya[b-1][f-1][r-1]+=v;
            }
            break;
        case 3:
            if(kousya[b-1][f-1][r-1]<10){
              kousya[b-1][f-1][r-1]+=v;
            }
            break;
        case 4:
            if(kousya[b-1][f-1][r-1]<10){
              kousya[b-1][f-1][r-1]+=v;
            }
      }
    }

    for(int i=0;i<kousya.length;i++){
      for(int j=0;j<kousya[i].length;j++){
        for(int k=0;k<kousya[i][j].length;k++){
          if(k<kousya[i][j].length){
            System.out.print(" ");
          }
          System.out.print(kousya[i][j][k]);
        }
        System.out.println();
        if(j==kousya[i].length-1 && i!=kousya.length-1){
          System.out.println("####################");
        }
      }
    }

  }
}


Measured memory_bytes: 28968
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }
//string al="abcdefghijklmnopqrstuvwxyz";
//vector< vector<int> > v (size1, vector<int>(size2) );
//山i->ダムi-1,i



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;cin>>N;
    vector<ll> A(N);
    vector<ll> a(N);
    FOR(i,0,N){
        cin>>A[i];A[i]*=2;
    }
    ll sum=0;
    FOR(i,0,N)sum+=A[i];sum/=2;
    //A2=a0   +a2 8=4+4
    //A0=a0+a1 
    //A1=   a1+a2
    //a[0]=sum-A[2]-A[4]
    FOR(i,0,(N-1)/2){
        sum-=A[i*2+1];
    }
    a[0]=sum;
    FOR(i,0,N-1){
        a[i+1]=A[i]-a[i];
    }
    
    FOR(i,0,N)cout<<a[i]<<' ';

}
//601

Measured memory_bytes: 2944
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int n,ans=1;
	scanf("%d", &n);
	for (int i = 1;i <= 3;i++)
	{
		ans *= n;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
n=input()
cnt1=len(n)
cnt2=0
cnt3=0

x="0"
for i in range(cnt1):
	if n[i] != x:
		cnt2+=1
	if x=="0":
		x="1"
	else:
		x="0"

x="1"
for i in range(cnt1):
	if n[i] != x:
		cnt3+=1
	if x=="0":
		x="1"
	else:
		x="0"

if cnt2 < cnt3:
	print(cnt2)
else:
	print(cnt3)

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

int main()
{
  char s[128];
  unsigned long long k;
  cin >> s >> k;
  k--;
  for(int i = 0; i < k; i++)
  {
    if(s[i] == '1')
    {
      continue;
    }
    else
    {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << s[k] << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n-2):
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    dp[n-1] = min(dp[n-1],dp[n-2]+abs(h[n-1]-h[n-2]))
    print(dp[n-1])
#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 55916
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String S_2 = S.replace("BC","D");
		long cnt=0L;
		int cnt_a=0;
		for (int i=0;i<S_2.length();i++) {
			if (S_2.charAt(i)=='A') {
				cnt_a++;
			} else if (S_2.charAt(i)=='D') {
				cnt+=cnt_a;
			} else {
				cnt_a=0;
			}
		}
		System.out.println(cnt);
	}
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
int second[15];

void prepare(){
    
    rep2(i,10){
        second[i]=(1<<(i-1));
    }

}


int main(){
    int d,g;
    cin>>d>>g;
    long long p[d+1];
    long long c[d+1];
    rep2(i,d){
        cin>>p[i]>>c[i];
    }
    prepare();

    long long ans=INF;
    for(int bit=0;bit<(1<<d);bit++){
        long long sum=0;
        long long now=0;
        for(int i=d;i>0;i--){
            if(bit&second[i]){
                long long  solved=ceil((double)(g-sum)/(100*i));
                solved=min(solved,p[i]);
                //cout<<solved<<" ";
                if(solved==p[i])sum+=c[i];

                sum+=solved*100*i;
                now+=solved;
            }
            if(sum>=g){
            ans=min(now,ans);
            break;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){

    int H, W;
    cin >> H >> W;
    int cnt = 0;
    for(int y = 0; y < H; y++){
        for(int x = 0; x < W; x++){
            char c;
            cin >> c;
            if(c == '#')cnt++;
        }
    }
    if(cnt == H + W - 1)cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


int main() {
    LL A;cin >> A;
    double B;cin >> B;
    double C = B * 10000.0;
    C = round(C);

    LL D = (LL)(C);  
    D /= 100;

    LL ans = A*D;
    ans /= 100;

    cout << ans << endl;

    


}

Measured memory_bytes: 3780
k=list(map(int,input().split()))
n=k[0]
l=k[1]
if l>0:
  print(int((n*l+(n+1)*n/2-n-l)))
elif l+n-1<0:
  print(int((n*l+(n+1)*n/2-n-(l+n-1))))
else:
  print(int((n*l+(n+1)*n/2-n)))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	reverse(v.begin(),v.end());
	int ans=0;
	int val=0;
	for(int i=1;i<=n;i++){
		if(v[i-1]<=v[i])val++;
		else val=0;
		ans=max(ans,val);
	}
	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int x,a,b; cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b)){
        cout<<'A'<<endl;
    }
    else cout<<'B'<<endl;
}





Measured memory_bytes: 256
def main():
    n, Y = map(int, input().split())
    ans = [-1, -1, -1]
 
    for x in range(n + 1):
        for y in range(n - x + 1):
            if x * 10000 + y * 5000 + (n - x - y) * 1000 == Y:
                ans = [x, y, (n - x - y)]
                break
    print(*ans)
 
main()

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(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;
}

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

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

ll getScore(vector<bool> givingList) {
    ll ans = 0;
    for (bool b : givingList) {
        if (b) {
            ans++;
        }
    }
    return ans;
}

ll calcPath(vector<ll> holdingTrashes, ll X) {
    ll score = 0;
    ll cost = 1;
    score += holdingTrashes[0];
    holdingTrashes.push_back(0);
    FOR(i, 1, holdingTrashes.size()) {
        cost++;
        score += (holdingTrashes[i - 1] - holdingTrashes[i]) * cost * cost;
    }
    score += X * holdingTrashes.size();
    return score;
}

int main() {
    ll N, M, X, Y;
    vector<ll> XList, YList;
    cin >> N >> M >> X >> Y;
    XList.push_back(X);
    YList.push_back(Y);
    REP(i, N) {
        int x;
        cin >> x;
        XList.push_back(x);
    }
    REP(i, M) {
        int x;
        cin >> x;
        YList.push_back(x);
    }
    sort(XList.begin(), XList.end(), greater<ll>());
    ll maxX = XList[0];
    sort(YList.begin(), YList.end());
    ll minY = YList[0];
    if (maxX < minY) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int N;
    string resl, resm, resr;
    cin >> N;
    cout << 0 << endl;
    cin >> resl;
    if (resl == "Vacant")return 0;
    cout << N - 1 << endl;
    cin >> resr;
    if (resr == "Vacant")return 0;

    int left = 0, right = N - 1;

    for (;;) {
        int m = (left + right) / 2;
        cout << m << endl;
        cin >> resm;
        if (resm == "Vacant")return 0;
        if (((m - left) % 2 == 0) == (resl == resm)) {
            //空席は後半
            resl = resm;
            left = m;
        } else {
            //空席は前半
            resr = resm;
            right = m;
        }
    }
}


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

using namespace std;

int main(void){
    string str1, str2;
    cin >> str1 >> str2;
    int n1 = str1.length();
    int n2 = str2.length();
    
    int dp[n1+1][n2+1];
    for (int i=0;i<=n1;i++){
        for(int j=0;j<=n2;j++){
            if (i == 0 || j == 0){
                dp[i][j] = 0;
            }else if (str1[i-1] == str2[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string res = "";
    if (dp[n1][n2] == 0){
        cout << res << endl;
    }else{
        int i = n1, j = n2;
        while (i > 0 && j > 0){
            if (str1[i-1] == str2[j-1]){
                res = res + str1[i-1];
                i--;j--;
            }else{
                if (dp[i-1][j] > dp[i][j-1]){
                    i--;
                }else{
                    j--;
                }
            }
        }

        reverse(res.begin(), res.end());
        cout << res << endl;
    }
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);
    vector<ll> D(N);

    REP(i, N){
        cin >> A[i] >> B[i];
    }
    REP(i, N){
        cin >> C[i] >> D[i];
    }

    BipartiteMatching bm(N + N);

    REP(i, N){
        REP(j, N){
            // cout << i << " " << j << endl;
            if((A[i] < C[j]) && (B[i] < D[j])){
                bm.add_edge(i, N + j);
                // cout << i << " " << j << endl;
            }
        }
    }

    // BipartiteMatching bm(X + Y);
    // for(int i = 0; i < E; i++) {
    //     int a, b;
    //     cin >> a >> b;
    //     bm.add_edge(a, X + b);
    // }

    cout << bm.bipartite_matching() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; scanf("%d",&n);
    int b[n-1];
    int ans = 0;
    for (int i = 0; i < n-1;i++){
        scanf("%d",&b[i]);
        if (i == 0) ans += b[i];
        else ans += min(b[i-1],b[i]);
    }
    ans += b[n-2];
    printf("%d",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define MAXV 10001

int main(){
    int N, M, cnt, t;
    cin >> N >> M;
    cnt = 0;
    rep(i, M){
        cin >> t;
        cnt += t;
    }
    if(N - cnt < 0){
        cout << "-1" << endl;
    } else {
        cout << N-cnt << endl;
    }

}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

const int NMAX = 100000 + 5;
vector <int> graph[NMAX];

deque <int> sol;
bool vis[NMAX];

int main()
{
    ios_base :: sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    for (int i = 1; i <= M; ++ i) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    sol.push_back(1);
    vis[1] = 1;

    int node = 1;
    while (1) {
        bool found = false;
        for (auto it: graph[node])
            if (!vis[it]) {
                node = it;
                vis[node] = true;
                sol.push_back(node);
                found = true;
                break;
            }
        if (!found)
            break;
    }

    node = 1;
    while (1) {
        bool found = false;
        for (auto it: graph[node])
            if (!vis[it]) {
                node = it;
                vis[node] = true;
                sol.push_front(node);
                found = true;
                break;
            }
        if (!found)
            break;
    }

    cout << sol.size() << '\n';
    for (int i = 0; i < sol.size(); ++ i)
        cout << sol[i] << " \n"[i + 1 == sol.size()];
    return 0;
}


Measured memory_bytes: 6784
#include <stdio.h>

int selection(int a[],int b)
{
  int l,m,n,o,p=0;
  for(l=0;l<b-1;l++){
    m=l;
    for(n=l;n<b;n++){
      if(a[n]<a[m]){
	m=n;
      }
    }
    o=a[l];
    a[l]=a[m];
    a[m]=o;
    if(l!=m){
      p++;
    }
  }
  return p;
}

  int main(){
  int A[100],i,j,k;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&A[i]);
  }
  j=selection(A, k);
  for(i=0;i<k;i++){
    if(i>0){
      printf(" ");
	}
      printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",j);
  return 0;
}
  



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		init(n);
		for(int i = 0; i < m; i++) {
			if(!unite(sc.nextInt(), sc.nextInt(), sc.nextInt())) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	final static int MAX_N = 1000000;
	static int[] par = new int[MAX_N];
	static int[] rank = new int[MAX_N];
	static int[] diff_weight = new int[MAX_N];
	static void init(int n) {
		for(int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
			diff_weight[i] = 0;
		}
	}
	static int root(int x) {
		if(par[x]==x) {
			return x;
		} else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];//累積和を取る
			return par[x] = r;
		}
	}
	static boolean same(int x, int y) {
		return root(x)==root(y);
	}
	static boolean unite(int x, int y, int w) {
		//xとyそれぞれについて、rootとの重み差分を補正
		w += (weight(x)-weight(y));

		x = root(x);
		y = root(y);
		if(x == y) {
			if(diff(x, y)==w) {
				return true;
			} else {
				return false;
			}
		}

		//rank[x] >= rank[y]になるようにswap
		if(rank[x] < rank[y]) {
			int temp = x;
			x = y;
			y = temp;
			w = -w;
		}

		if(rank[x] == rank[y]) rank[x]++;
		par[y] = x;

		diff_weight[y] = w;

		return true;
	}
	static int weight(int x) {
		root(x);
		return diff_weight[x];
	}
	static int diff(int x, int y) {
		return weight(y) - weight(x);
	}
}

Measured memory_bytes: 160548