akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] seq = new int[n+2];
      seq[0] = seq[n+1] = 0;
      int[] d = new int[n+1];

      String line = in.readLine();
      char regex = ' ';
      boolean isContinue = true;
      for(int i=1, offset=0,next=0; isContinue; offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        seq[i++] = Integer.parseInt(line.substring(offset,next));
      }

      int sum=0;
      StringBuilder buf = new StringBuilder();
      for(int i=0; i<=n; i++) {
        sum += d[i] = Math.abs(seq[i+1] - seq[i]);
      }
      // sum += Math.abs(seq[n]);

      int ans=0;
      for(int i=1; i<=n; i++) {
        // ans -= Math.abs(seq[i] - seq[i-1]);
        // ans -= Math.abs(seq[i+1] - seq[i]);
        ans = sum - d[i-1] - d[i]
            + Math.abs(seq[i+1] - seq[i-1]);
        buf.append(ans).append('\n');
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 43040
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}


int main()
{	
  boost
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif
ll n;
cin>>n;
if(n>=30)
	cout<<"Yes\n";
else
	cout<<"No\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N;
vector<ll> v[4], w[4];

signed main(){
    cin >> N;
    ll x, y;
    REP(i, N){
        cin >> x >> y;
        v[0].push_back(x + y); w[0].push_back(-x - y);
        v[1].push_back(-x + y); w[1].push_back(x - y);
        v[2].push_back(x - y); w[2].push_back(-x + y);
        v[3].push_back(-x - y); w[3].push_back(x + y);
    }
    REP(i, 4){
        sort(ALL(v[i]), greater<ll>());
        sort(ALL(w[i]), greater<ll>());
    }
    ll ans = 0;
    REP(i, 4) ans = max(ans, v[i][0] + w[i][0]);
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 15924
#include<bits/stdc++.h>
using namespace std;
int i,j,k=0,ta,n,arr[1000],str[1000];
char s[1000],t[1000];
int main()
{
    scanf("%s",s);
    if(s[0]!='A'){
        printf("WA\n");
        return 0;
    }
    for(i=2;i<strlen(s)-1;i++){
        if(s[i]=='C')
            k++;
    }
    if(k==0||k>1){
        printf("WA\n");
        return 0;
    }
    k=0;
    for(i=0;i<strlen(s);i++){
        if(s[i]<='Z')
            k++;
    }
    if(k>2){
        printf("WA\n");
        return 0;
    }
    printf("AC\n");
    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
dist=[[0,1],[1,0],[-1,0],[0,-1]]
ans='Yes'

for h in range(H):
    for w in range(W):
        if S[h][w]=='#':
            for dh,dw in dist:
                if 0<=h+dh<=H-1 and 0<=w+dw<=W-1 and (S[h+dh][w+dw]=='#' or S[h+dh][w+dw]=='o'):
                    S[h+dh][w+dw]='o'
                    S[h][w]='o'

for s in S:
    if '#' in s:
        ans='No'
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int W,H,n; cin >> H >> W >> n;
  int tmp = max(H,W);
  cout << (n+tmp-1)/tmp << endl;

}

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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] point = new int[n];
		List<Integer> num = new ArrayList<>();
		int sum = 0;
		for (int i = 0; i < n; i++) {
			point[i] = scanner.nextInt();
			sum += point[i];
			if (point[i] % 10 != 0) {
				num.add(point[i]);
			}
		}
		if (sum % 10 != 0) {
			System.out.println(sum);
		} else {
			if (num.size() == 0) {
				System.out.println(0);
			} else {
				int min = 101;
				for (Integer i : num) {
					if (i < min) {
						min = i;
					}
				}
				System.out.println(sum-min);
			}
		}
		scanner.close();
	}
}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int x,a;
	cin >> x >>a;
	cout << (x<a?0:10) << endl;
}


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

int main(int argc, char const *argv[])
{
    char a; cin >> a;
    if (isupper(a)) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 1
#define nl          '\n'
#define IOS()       {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; i++)
#define forj(n)			for(int j = 0; j < n; j++)
#define fork(n)			for(int k = 0; k < n; k++)
#define forl(n)			for(int l = 0; l < n; l++)
#define N 100010

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef long double ld;

int main() {
	IOS();	//desyncs with stdio and unties cin and cout
		
	int h,w;
	cin >> h >> w;
	vbool visited(h*w, false);
	queue<int> cur;
	char x;
	fori(h) {
		forj(w) {
			cin >> x;
			if (x == '#') {
				cur.push(i*w+j);
				visited[i*w+j] = true;
			}
		}
	}

	int total = 0;
	int counter = cur.size();
	while(!cur.empty()) {
		int curr = cur.front();
		cur.pop();
		//trace(curr); trace(counter);
		if (curr%w != 0 && !visited[curr-1]) {
			// add left
			cur.push(curr-1);
			visited[curr-1] = true;
		}
		if ((curr+1)%w != 0 && !visited[curr+1]) {
			// add right
			cur.push(curr+1);
			visited[curr+1] = true;
		}
		if (curr >= w && !visited[curr-w]) {
			// add top
			cur.push(curr - w);
			visited[curr-w] = true;
		}
		if (curr < (h*w-w)&& !visited[curr+w]) {
			// add bottom
			cur.push(curr + w);
			visited[curr+w] = true;
		}
		counter--;
		if (counter == 0) {
			total++;
			counter = cur.size();
		}
	}
	if (total > 0) total--;
	cout << total << nl;
	
	return 0;
}


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

int main(){
    int a[102];
    int b[102];
    int c[52];
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
        c[i]=0;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[j]==i+1 || b[j]==i+1){
                c[i]++;
            }
        }
    }

    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }
}

Measured memory_bytes: 256
///                ..:: In The Name Of God ::..
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define endl    '??/n' 
#define INF 2e9
#define int ll
#define vi          vector<int>
#define vii         vector<pii>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

signed main(){

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = (double)W * H / 2;

    printf("%.10f %d\n", ans, x + x == W && y + y == H);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	ll A,B;
	cin >> A >> B;
	
	if(A == B){
		cout << 1 << endl;
		return 0;
	}
	
	ll a[62],b[62];
	ll A_ = A , B_ = B;
	rep(i,62){
		a[i] = A_%2; A_ /= 2;
		b[i] = B_%2; B_ /= 2;
	}
	
	ll C=0;
	ll s=-1,t=-1;
	rrep(i,62){
		C *= 2;
		if(s == -1){
			if(a[i] != b[i]){
				s = i;
			}
			C += b[i];
		}
		else if(t == -1){
			if(b[i] == 1)t = i;
		}
	}
	
	cout << C-A+min((((ll)1)<<s),(((ll)1)<<(t+1))+C-A) << endl;
}



Measured memory_bytes: 384
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

from itertools import groupby
N = int(input())
P = prime_decomposition(N)
ans = 0
for v, g in groupby(P):
    n = len(list(g))
    for i in range(1, 100000):
        n -= i
        if n >= 0:
            ans += 1
        else:
            break
print(ans)


Measured memory_bytes: 9204
S = input()
a = bool(0)
b = bool(0)
c = bool(0)
for i in range(3):
    if(S[i] is "a"):a = 1
    if(S[i] is "b"):b = 1
    if(S[i] is "c"):c = 1
if(a and b and c):print("Yes")
else:print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    string s; cin >> s;
    string t; cin >> t;
    int ns = s.size();
    int nt = t.size();
    if (nt > ns){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    bool at = true;
    for (int i = ns - nt; i >= 0; i--){
        at = true;
        string ss = s.substr(i,nt);
        rep(j,nt){
            if (ss[j] != '?' && ss[j] != t[j]){
                at = false;
                break;
            }
        }
        if (at){
            rep(j,nt){
                s[i+j] = t[j];
            }
            break;
        }
    }
    if (at){
        rep(i,ns){
            if (s[i] == '?') s[i] = 'a';
        }
        cout << s << endl;
    }
    else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string a[105];
int main()
{
	cin>>a[1];
	for(int i=1;i<=1;i++)
		if(a[i].size()>2)
			cout<<a[i][0]<<a[i].size()-2<<a[i][a[i].size()-1]<<endl;
		else
			cout<<a[i]<<endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  map<string, int> M;
  for (int i = 0; i < N; i++) {
    string S; cin >> S;
    if (!M.count(S)) M[S] = 1;
    else M[S]++;
  }
  int cnt = 0;
  for (auto p : M) {
    if (p.second > cnt) cnt = p.second;
  }
  vector<string> A;
  for (auto p : M) {
    if (p.second == cnt) A.push_back(p.first);
  }
  sort(A.begin(), A.end());
  for (auto s : A) cout << s << endl;
}

Measured memory_bytes: 26868
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
const int inf = 1001001001;
typedef long long ll;

int main(){
    ll x; cin >> x;
    for(ll a=-2000; a<2000; a++){
        ll a5 = a*a*a*a*a;
        for(ll b=-2000; b<2000; b++){
            ll b5 = b*b*b*b*b;
            if(a5-b5 == x){
                cout << a << " " << b << endl;
                return 0;
            }//else if(a5+b5 == x){
            //    cout << a << " " << -b << endl;
            //    return 0;                
            //}
        }
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    vector<int> D;
    void input() {
        cin >> N;
        D.resize(N);
        REP(i, N) { cin >> D[i]; }
    }
    void output() {
        vector<int> cnt(13);
        cnt[0] = 2;
        cnt[12] = 1;
        REP(i, N) { cnt[D[i]]++; }
        if (*max_element(cnt.begin(), cnt.end()) >= 3) {
            cout << 0 << endl;
            return;
        }
        vector<int> two = {0}, one;
        FOR(i, 1, 12) {
            if (cnt[i] == 2) {
                two.emplace_back(i);
                two.emplace_back(24 - i);
            } else if (cnt[i] == 1) {
                one.emplace_back(i);
            }
        }
        if (cnt[12] == 2) two.emplace_back(12);
        int n = one.size();
        int res = 0;
        REP(bit, 1 << n) {
            vector<int> v = two;
            REP(j, n) {
                if (bit >> j & 1) {
                    v.emplace_back(one[j]);
                } else {
                    v.emplace_back(24 - one[j]);
                }
            }
            int mn = 12;
            REP(i, N) {
                FOR(j, i + 1, N + 1) {
                    int d = abs(v[i] - v[j]);
                    d = min(d, 24 - d);
                    mn = min(mn, d);
                }
            }
            res = max(mn, res);
        }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3652
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,L,n,ans=0,gen=0;cin>>L>>n;
	deque<llint>X(n+1);
	for(i=1;i<=n;i++){cin>>X[i];}
	ans=X[n];gen=X[n];
	int tas=n;
	for(i=0;i<=2*n-2;i++){
		if(i%2==0){
			llint it=X.back();
			gen-=X.back()-X[n-1];
			X.pob();X.puf(it-L);
		}else{tas--;}
		gen-=X.back()-X[tas];
		gen+=X[tas]-X.front();
		maxeq(ans,gen);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 3005;
int dp[maxn][maxn];

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    REPP(i, 1, n + 1) REPP(j, 1, m + 1) {
        dp[i][j] = dp[i][j - 1];
        dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        if (s[i - 1] == t[j - 1]) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }
    int x = n, y = m;
    string ans = "";
    while (x && y) {
        if (dp[x - 1][y] == dp[x][y]) x--;
        else if (dp[x][y - 1] == dp[x][y]) y--;
        else {
            ans.push_back(s[x - 1]);
            x--, y--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35456
/*input
10
5 9 5 9 8 9 3 5 4 3
*/
#include <bits/stdc++.h>
using namespace std;
int a[100005],n;
class SegmentTree{
	vector<int> segtree;
	public:
	SegmentTree(int size){
		segtree.resize(4*size,0);
	}
	void update(int u, int a, int b, int i, int j, int x){
		if(j<a || i>b || a>b) return;
		if(j>=b && i<=a){
			segtree[u]+=x;
			return;
		}
		update(u*2,a,(a+b)/2,i,j,x); update(u*2+1,(a+b)/2+1,b,i,j,x);
		segtree[u]=segtree[u*2]+segtree[u*2+1];
	}
	void update(int i, int x){
		update(1, 0, segtree.size()/4-1, i, i, x);
	}
	int query(int u, int a, int b, int i, int j){
		if(j<a || i>b || a>b) return 0;
		if(j>=b && i<=a) return segtree[u];
		return query(u*2,a,(a+b)/2,i,j)+query(u*2+1,1+(a+b)/2,b,i,j);
	}
	int query(int i, int j){
		return query(1,0,segtree.size()/4-1,i,j);
	}
};
bool check(int m){
	vector<int> pref(n+1);
	for(int i=1;i<=n;++i)
		pref[i] = pref[i-1] + (a[i]>=m?1:-1);
	SegmentTree seg(2*n+5);
	int64_t CNT = 0;
	seg.update(n,1);
	for(int i=1;i<=n;seg.update(pref[i++]+n,1))
		CNT += seg.query(0,pref[i]+n);
	return 2*CNT >= (int64_t) n*(n+1)/2;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;cin>>a[i++]);
	int low = 1, high = 1e9, mid;
	while(low<high)
		if(check(mid = low+high+1>>1)) low = mid;
		else high = mid - 1;
	cout<<low;
}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a;
   string s;
   cin >>a>>s;
   if(a>=3200){
   cout<<s<<endl;
   }
   else{
   cout<<"red"<<endl;
   }
}

Measured memory_bytes: 384
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

pre = [0, 0, 0]
jdg = True
for t, x, y in txy:
    d = abs(x - pre[1]) + abs(y - pre[2])
    tt = t - pre[0]
    if tt - d >= 0 and (tt - d) % 2 == 0:
        jdg = True
        pre = [t, x, y]
    else:
        jdg = False
        break
        
print('Yes' if jdg else 'No')

Measured memory_bytes: 27380
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL R;
	cin >> R;
	cout << setprecision(12) << 2 * R * 3.14159265 << "\n";
	return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector< vector<int> > G(n, vector<int>(n, 0));
	for(int i = 0; i < n; ++i) {
		int u, k, v;
		cin >> u >> k;
		u--;
		
		for(int j = 0; j < k; ++j) {
			cin >> v;
			v--;
			G[u][v] = 1;
		}
	}
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			cout << G[i][j];
			
			if( j != n - 1 ) cout << " ";
		}
		
		cout << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

int main(){
    ll x; cin>>x;
    cout<<1-x<<endl;
}

Measured memory_bytes: 3616
n=int(input())
ns=int(n**0.5)
nms=int((n-1)**0.5)
p=[n]
for i in range(2,ns+1):
  if n%i==0:
    p.append(i)
    if i!=n//i:
      p.append(n//i)

def chd(x,k):
  while x%k==0:
    x=x//k
  return int((x%k)==1)

count=0
for i in p:
  count+=chd(n,i)
for i in range(2,nms+1):
  if (n-1)%i==0:
    count+=1
    if i!=(n-1)//i:
      count+=1
print(count+1-(n==2))

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

int main(){
    int n, m, t[100], p[100], x[100], sum = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> p[i] >> x[i];
    }
    for(int i=0;i<m;i++){
        int j = p[i]-1;
        cout << sum - t[j] + x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int x;
    cin >> x;
    mp[x]++;
  }
  int m;
  cin >> m;
  rep(i,m){
    int t;
    cin >> t;
    if (mp[t] > 0){
      mp[t]--;
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
   

}


Measured memory_bytes: 12948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N = 1e5 + 3;
	const int base = 1e9 + 7;
	int a[N],f[102][N],sum[102][N];
	int n,k;

	int calc(int i,int j){
		int l = max(0,j - a[i]);
		int r = j;
		return submod(sum[i - 1][r],l - 1 < 0 ? 0 : sum[i - 1][l - 1],base);
	}

    void solve(){
    	cin>>n>>k;
    	for(int i = 1;i <= n;++i){
    		cin>>a[i];
    	}
    	for(int i = 0;i <= a[1];++i){
    		f[1][i] = 1;
    		sum[1][i] = f[1][i];
    	}
    	for(int i = 0;i <= k;++i){
    		sum[1][i] = addmod(sum[1][i],sum[1][i - 1],base);
    	}
    	for(int i = 2;i <= n;++i){
    		for(int j = 0;j <= k;++j){
    			f[i][j] = addmod(f[i][j],calc(i,j),base);
    			sum[i][j] = f[i][j];
    		}
    		for(int j = 1;j <= k;++j){
    			sum[i][j] = addmod(sum[i][j],sum[i][j - 1],base);
    		}
    	}
    	cout<<f[n][k];
    }
}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


Measured memory_bytes: 79744
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

template<class Func>auto order_by(Func func)
{
	return [=](auto x, auto y)
	{
		return func(x) < func(y);
	};
}


void Main()
{
	int N, Q;
	std::cin >> N >> Q;
	std::string map;
	std::cin >> map;
	std::vector<std::pair<char, bool>> query(Q);
	for (auto& p : query)
	{
		char a, b;
		std::cin >> a >> b;
		p.first = a;
		p.second = b == 'R';
	}
	auto left = boost::upper_bound(boost::irange(0, N), false, order_by([&](int i)
		{
			for (auto p : query)
			{
				if (p.first == map[i])
				{
					i += p.second ? 1 : -1;
				}
				if (i < 0)
				{
					return false;
				}
				else if (N <= i)
				{
					return true;
				}
			}
			return true;
		}));
	auto right = boost::upper_bound(boost::irange(0, N), false, order_by([&](int i)
		{
			for (auto p : query)
			{
				if (p.first == map[i])
				{
					i += p.second ? 1 : -1;
				}
				if (i < 0)
				{
					return false;
				}
				else if (N <= i)
				{
					return true;
				}
			}
			return false;
		}));
	std::cout << right - left << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    vector<int> data;
    int n = -1, counter = 1;

    while(true) {
        cin >> n;
        if(n == 0) break;
        data.push_back(n);
    }

    rep(i, data.size()) {
        cout << "Case " << i+1 << ": " << data.at(i) << endl;
    }
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e7+1;
int sp[N];
int p[N];
void sieve() {
	for (int i = 2; i < N; i++) {
		if (!p[i]) {
			// cout << i << endl;
			sp[i] = i;
			for (int j = 2*i; j < N; j+=i) {
				if (!sp[j])
					sp[j] = i;
				p[j] = 1;
			}
		}
	}	
}
ll f(int num) {
	// cout << "Came here for " << num << endl;
	ll ret = 1;
	while (num > 1) {
		int pd = sp[num];
		int ctr = 0;
		while (num % pd == 0) {
			ctr++;
			num /= pd;	
		}
		ret *= (ctr+1);
	}
	return ret;
}
int main() {
	sieve();
	// cout << "Done";
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		ll a = f(i);
		sum += a*i;
	}
	cout << sum;
	return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    cin.ignore();

    vector<string> s(H);
    for (int i = 0; i < H; i++)
    {
        getline(cin, s[i]);
    }

    vector<vector<char>> answer(H, vector<char>(W));

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (s[i][j] == '#')
            {
                answer[i][j] = '#';
            }
            else
            {
                int r = 0;
                for (int l = i - 1; l <= i + 1; l++)
                {
                    for (int m = j - 1; m <= j + 1; m++)
                    {

                        if ((l == i && m == j ) || l < 0 || l >= H || m < 0 || m >= W)
                        {
                        }
                        else
                        {
                            r += (s[l][m] == '#' ? 1 : 0);
                        }
                    }
                }
                answer[i][j] = '0' + r;
            }
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << answer[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
p = a*x + b*y
q = 2*c*max(x,y)
r = 2*c*x + b*(y-x)
s = 2*c*y + a*(x-y)
if x >=y:
        print(min(p,q,s))
else:
        print(min(p,q,r))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
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;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

int main() {
    int N, M, cnt = 0; ignore_ret(scanf("%d %d",&N,&M));
    vector<int> L(M, 0);
    rep(i, N) {
        int K; ignore_ret(scanf("%d",&K));
        rep(j, K) {
            int a; ignore_ret(scanf("%d",&a));
            L.at(a - 1)++;
        }
    }
    rep(i, M) {
        if (L.at(i) == N) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

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



int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
   	string s;
   	cin>>s;
   	int n = s.length();
   	string s2 = s;
   	int count1 = 0, count2 = 0;
   	for(int i = 1; i < n; i++) {
   		if(s[i] == s[i-1]) {
   			s[i] ^= 1;
   			count1++;
   		}
   	}

   	cout<<count1;
	return 0;		
}



Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	a=0;
	b=-1;
	while(a+b!=0){
		while(a+b>0){
			for(c=0;c<b;c++){
				printf("#");
			}
			printf("\n");
			for(c=2;c<a;c++){
				printf("#");
				for(d=2;d<b;d++){
					printf(".");
				}
				printf("#\n");
			}
			for(c=0;c<b;c++){
				printf("#");
			}
			a=-1;
			b=-1;
			printf("\n\n");
		}
		scanf("%d%d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 588
# coding: utf-8

a = [int(input()) for _ in range(5)]
k = int(input())
flag = True

for i in range(5):
  for j in range(5):
    if abs(a[i] - a[j]) > k:
      flag = False
      break

if flag:
  print('Yay!')
else:
  print(':(')

Measured memory_bytes: 3060
#include <iostream>
#define TEST cout << endl << "test "
using namespace std;

int main(void){
  int n,s[100001],q,t[50001],count = 0;
  cin >> n; for(int i = 0; i < n; i++)cin >> s[i];
  cin >> q; for(int i = 0; i < q; i++)cin >> t[i];

  for(int i = 0; i < q; i++){
    int left = 0,right = n;
    while(left < right){
      int mid = (left + right) / 2;
      if(s[mid] == t[i]){
        count++;
        break;
      }
      else if(t[i] < s[mid])right = mid;
      else left = mid + 1;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3604
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-04-16 18:59:37
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 5e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , Z , W , A[MAXN] , mn[MAXN] , mx[MAXN];

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

    cin >> n >> Z >> W;
    A[0] = W;
    for(ll i = 1 ; i <= n ; i++)    cin >> A[i];
    mn[n] = mx[n] = abs(A[n] - A[n - 1]);
    for(ll i = n - 1 ; i >= 1 ; i--){
        mn[i] = INF , mx[i] = -INF;
        for(ll j = i ; j < n ; j++){
            mn[i] = min(mn[i] , mx[j + 1]);
            mx[i] = max(mx[i] , mn[j + 1]);
        }
        ll val = abs(A[n] - A[i - 1]);
        mn[i] = min(mn[i] , val);
        mx[i] = max(mx[i] , val);
    }
    cout << mx[1] << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

int main() {
	int data_sets_num = 0;		//??\???????????????????????????????????°
	std::vector<string> result;
	
	cin >> data_sets_num;
	for (int i = 0; i < data_sets_num; i++) {
		int first, second, third;

		cin >> first >> second >> third;
		if (
			(first * first == second * second + third * third) ||
			(second * second == first * first + third * third) ||
			(third * third == second * second + first * first)
			) {
			result.push_back("YES");
		}
		else {
			result.push_back("NO");
		}
	}

	for (unsigned int j = 0; j < result.size(); j++) {
		cout << result[j] << endl;
	}

	return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>
#include <stdlib.h>
#define line 1000001
struct data{
  char name[11];
  int time;
};

struct data data[line];
void cal(int);
struct data deque();
void enqueue(struct data);
int head=0,tail;
  
int main(){
  int n,q,i,a,j;
 
  scanf("%d%d",&n,&q);

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

   
  while(head!=tail){
  
   
    cal(q);

    
  }


  return 0;
}

void cal(int q){

  static int time=0;
  struct data b;
  int r;

  b=deque(); 

  r=b.time-q;

  if(r>0){
    time+=q;
    b.time-=q;
    
    enqueue(b);
  }
  else {
    time+=b.time;
    printf("%s %d\n",b.name,time);
    
  }

}

struct data deque(){
  struct data a;
  a=data[head];
  head=(head+1)%line;
  return a;
}
void enqueue(struct data a){

  data[tail]=a;
  tail=(tail+1)%line;
  
}

Measured memory_bytes: 4692
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  int A, B;
  int a1, a2, a3, max;

  cin >> A >> B;

  a1 = A+B;
  a2 = A-B;
  a3 = A*B;

  max = a1;

  if( max < a2 ){
    max = a2;
  }
  if( max < a3 ){
    max = a3;
  }

  cout << max << endl;

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func run() int {
	var s string
	fmt.Scanf("%s", &s)

	week := make(map[string]int, 8)

	week["SUN"] = 7
	week["MON"] = 6
	week["TUE"] = 5
	week["WED"] = 4
	week["THU"] = 3
	week["FRI"] = 2
	week["SAT"] = 1

	fmt.Println(week[s])

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;

struct C {
    vector<ll> v_{};
    vector<ll> childs_{};
    ll N_{};
    string S_{};
    explicit C(string S) : S_(move(S)){
        N_ = S_.size();
    }
    vector<ll> resolve() {
        vector<ll> first_R_position_of_the_group{};
        vector<ll> positive_parity_count_of_the_group{};
        vector<ll> negative_parity_count_of_the_group{};
        ll num_groups = 0;
        for(ll i=0; i < N_-1; ++i) {
            if (S_[i] == 'R' && S_[i+1] == 'L') {
                first_R_position_of_the_group.emplace_back(i);
                ++num_groups;
            }
        }
        positive_parity_count_of_the_group.resize(num_groups);
        negative_parity_count_of_the_group.resize(num_groups);
        ll index = 0;
        for(ll first_R_pos : first_R_position_of_the_group) {
            ll i = 0;
            while(first_R_pos - i >= 0 && S_[first_R_pos-i]=='R') {
                if (i % 2 == 0) {
                   ++positive_parity_count_of_the_group[index];
                } else {
                    ++negative_parity_count_of_the_group[index];
                }
                ++i;
            }
            i = 1;
            while(
                    ((index == num_groups-1 && first_R_pos + i < N_ ) ||
                            (index != num_groups-1 && first_R_pos + i < first_R_position_of_the_group[index+1])) &&
                            S_[first_R_pos+i]=='L') {
                if (i % 2 == 0) {
                    ++positive_parity_count_of_the_group[index];
                } else {
                    ++negative_parity_count_of_the_group[index];
                }
                ++i;
            }
            ++index;
        }
        vector<ll> childs(N_, 0);
        index = 0;
        for(ll first_R_pos : first_R_position_of_the_group) {
            childs[first_R_pos] = positive_parity_count_of_the_group[index];
            childs[first_R_pos+1] = negative_parity_count_of_the_group[index];
            ++index;
        }
        return childs;
    }
};

int main() {
    string S;
    cin >> S ;
    C c{move(S)};
    auto&& ans = c.resolve();
    for(ll i=0; i < ans.size(); ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  
  vector<int> dp(N, 0);
  dp[0] = 0;
  dp[1] = abs(H[1] - H[0]);
  
  for (int i = 2; i < N; i++) {
    dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]));
  }
  
  cout << dp[N-1] << endl;      
}

Measured memory_bytes: 4048
#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];
    }

    int count = 1;
    for (int i=1; i<n; i++) {
        bool res = true;
        for (int j=0; j<i; j++) {
            if (v[j] > v[i]) res = false;
        }
        if (res == true) count++;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
bool cmp(char a,char b)
{
	return a>b;
}

int main()
{
	string x,y;
	cin>>x>>y;
	sort(x.begin(),x.end());
	sort(y.begin(),y.end(),cmp);
	if (x<y)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A(0), B(0), C(0), D(0);
  cin >> A >> B >> C >> D;
  const int L = A + B;
  const int R = C + D;
  
  if(L > R)
  {
   	cout << "Left" << endl; 
  }
  else if (L == R)
  {
   	cout << "Balanced" << endl;
  }
  else 
  {
   	cout << "Right" << endl; 
  }
    
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
participants = 0
i = 1
for s in S:
    if s == 'c':
        print('No')
        continue
    elif s == 'a':
        if participants < A+B:
            print('Yes')
            participants += 1
        else:
            print('No')
    elif s == 'b':
        if participants < A+B and i <= B:
            print('Yes')
            participants += 1
        else:
            print('No')
        i += 1
    



Measured memory_bytes: 9288
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s;
	std::cin >> s;
	const uint32 L = s.length();
	char d = s[0];
	bool b = 1;
	for (uint32 i = 1;i < L;++i) {
		if (s[i] != d) b = 0;
	}
	if (b) {
		std::cout << "0\n";
		return 0;
	}
	uint32 ans = L;
	for (char c = 'a';'a' <= c&&c <= 'z';++c) {
		uint32 cur = 1;
		std::string t = s;
		bool f;
		while (cur != L) {
			f = 1;
			for (uint32 i = 0;i < L - cur;++i) {
				if (t[i] == c || t[i + 1] == c) {
					t[i] = c;
				}
				else {
					f = 0;
				}
			}
			if (f) {
				ans = std::min(ans, cur);
				break;
			}
			++cur;
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 768
/*
	Name: F-冒泡排序 
	Author: RoseKey
	Date: 14/02/19 16:49
	Description: 模拟+找规律 
*/

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define pair pair<LL,LL>
#define space putchar(' ')
using namespace std;
    
template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    
template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int n;
LL ans;
LL b[100005];
struct qwq
{
	int num;
	int val;
	bool flag;
}a[100005];

inline bool cmp(qwq x,qwq y)
{
	return x.val<y.val;
}
//qwq
int main()
{
	read(n);
	for(RI i=1;i<=n;++i)
		read(a[i].val),a[i].num=i;
	stable_sort(a+1,a+n+1,cmp);
	for(RI i=1;i<=n;++i)
	{
		int k=i;
		int kk=a[i].val;
		int h=i%2;
		int hh=a[i].num%2;
		if(h==hh) a[i].flag=1;
		if(a[i].flag) continue;
	}
	for(RI i=1;i<=n;++i)
	{
		if(a[i].flag) continue;
		ans++;
	}
	if(ans==0)
	{
		print(0);
		return 0;
	}
	print(ans/2);
	return 0;
}

Measured memory_bytes: 2048