akhauriyash/Code-Regression huggingface dataset:
dice_ = [int(i) for i in input().split()]
dice = {
    (0,0,1):dice_[0],
    (0,-1,0):dice_[1],
    (1,0,0):dice_[2],
    (-1,0,0):dice_[3],
    (0,1,0):dice_[4],
    (0,0,-1):dice_[5]
}
rdice = {
    dice_[0]:(0,0,1),
    dice_[1]:(0,-1,0),
    dice_[2]:(1,0,0),
    dice_[3]:(-1,0,0),
    dice_[4]:(0,1,0),
    dice_[5]:(0,0,-1)
}

def cross(a,b):
	return(a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])
n = int(input())
for _ in range(n):
	a_,b_ = [int(i) for i in input().split()]
	a = rdice[a_]
	b = rdice[b_]
	print(dice[cross(a,b)])





Measured memory_bytes: 5608
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
int main()
{
	double x[4],y[4];
	while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3])
	{
		double vx[2],vy[2];
		for(int i=0;i<2;i++)
		{
			vx[i]=x[2*i+1]-x[2*i];
			vy[i]=y[2*i+1]-y[2*i];
		}
		if(add(vx[0]*vx[1],vy[0]*vy[1])==0) cout << "YES" << '\n' ;
		else cout << "NO" << '\n' ;
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
#include <ostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << "\n";
  }
  return os;
}

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

  int N;
  std::vector<int> a;

  cin >> N;
  a.resize(N);

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

  int ans = int(1e9);

  for (int i = -100; i < 101; ++i) {
    int tmp = 0;
    for (int j = 0; j < N; ++j) {
      tmp += (i - a[j]) * (
        i - a[j]);
    }

    ans = std::min(ans, tmp);
  }

  cout << ans << endl;

  system("pause");
  return 0;
}


Measured memory_bytes: 504
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let s=read::<String>().chars().collect::<Vec<char>>();
    let mut c=0;
    for i in 1..s.len(){
        if s[i as usize]<'a'{
            c+=if s[i as usize]=='C'{1}else{2}
        }
    }
    println!("{}",if s[0]!='A'||c!=1||s[1]<'a'||s[s.len()-1]<'a'{"WA"}else{"AC"})
}


Measured memory_bytes: 4352
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import Counter
from pprint import pprint

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

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = input()
if n[0]=="7" or n[1]=="7" or n[2]=="7":
    print("Yes")
else:
    print("No")

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

int h,w,m,a[300001],b[300001],p1,p2;
typedef pair<int,int> pi;
set<pi> st;

int main(){
	int i,j,x,y;
	cin>>h>>w>>m;
	vector<int> l,r;
	
	for(i=1;i<=m;++i){
		cin>>x>>y;
		st.insert(make_pair(x,y));
		a[x]++;
		b[y]++;
		if(a[x]>p1){
			l.clear();
			p1=a[x];
		}
		if(a[x]==p1)l.push_back(x);
		
		if(b[y]>p2){
			r.clear();
			p2=b[y];
		}
		if(b[y]==p2)r.push_back(y);
	}
	
	for(i=0;i<l.size();++i){
		for(j=0;j<r.size();++j){
			if(st.find(make_pair(l[i],r[j]))==st.end()){
				cout<<p1+p2;
				return 0;
			}
		}
	}
	
	cout<<p1+p2-1;
}




Measured memory_bytes: 21864
N = int(input())
A = sorted([(int(a), i) for i, a in enumerate(input().split())], key = lambda x: x[0])[::-1]
X = [0] + [-1<<100] * (N + 5)
for k, (a, i) in enumerate(A):
    X = [max(X[j] + abs(N - (k - j) - 1 - i) * a, X[j-1] + abs(j - 1- i) * a if j else 0) for j in range(N + 5)]
print(max(X))

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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int sum = 0;
  int max_l = 0;
  for(int i=0;i<n;i++) {
    int l;
    cin>>l;
    sum += l;
    max_l = max(l, max_l);
  }
  if (max_l < sum - max_l) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	int n;
	cin >> n;
	vector<string> vs(n), vans;
	map<char, ll> mc;
	REP(i, 26) mc['a' + i] = INF;
	string s;
	REP(i, n) {
		cin >> s;
		map<char, ll> mtmp;
		REP(j, s.size())
		{
			mtmp[s[j]]++;
		}
		REP(j, 26) mc['a' + j] = min(mc['a' + j], mtmp['a' + j]);
	}
	REP(i, 26)
	{
		REP(j, mc['a' + i]) cout << static_cast<char>('a' + i);
	}
	cout << endl;
}

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


int a[54][54];

int main() {
	int h, w;
	cin >> h >> w;
	string s;
	for (int j = 0; j <= h + 1; j++) {
		a[0][j] = 0;
		a[w + 1][j] = 0;
	}
	for (int i = 0; i <= w + 1; i++) {
		a[i][0] = 0;
		a[i][h + 1] = 0;
	}
	for (int i = 1; i <= w; i++) {
		cin >> s;
		for (int j = 1; j <= h; j++) {
			a[i][j] = (s[j - 1] == '#');
		}
	}
	int dx[4] = {1, 0, -1, 0};
	int dy[4] = { 0,-1,0,1 };
	for (int i = 1; i <= w; i++) {
		for (int j = 1; j <= h; j++) {
			if (a[i][j] == 1) {
				bool flag = 0;
				for (int k = 0; k < 4; k++) {
					flag |= (a[i + dx[k]][j + dy[k]] == 1);
				}
				if (!flag) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  int N; cin>>N;
  vector<int> A (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>A[i];
  }
  vector<int> B (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>B[i];
  }
  for (int i = 0; i < N-1; i++)
  {
    A[i+1] += A[i];
    B[N-2-i] += B[N-1-i];
  }
  int MAX = 0;
  for (int i = 0; i < N; i++)
  {
    chmax(MAX,A[i]+B[i]);
  }
  cout<<MAX<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {

	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	rep(i, N - 1) {
		cin >> B[i];
		A[i] = B[i];
	}
	A[N-1] = B[N - 2];
	for (int i = 1; i < N - 1; i++) {
		if (A[i] > B[i - 1]) {
			A[i] = B[i - 1];
		}
	}

	ll ans = 0;
	rep(i, N) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    deque<char> head, tail;
    ll countReverse = 0;
    REP(i, Q)
    {
        ll T;
        cin >> T;
        if (T == 1)
        {
            countReverse++;
        }
        else if (T == 2)
        {
            ll F;
            char C;
            cin >> F >> C;
            if (F == 1)
            {
                if (countReverse % 2 == 0) head.push_front(C);
                else if (countReverse % 2 == 1) tail.push_back(C);
            }
            else if (F == 2)
            {
                if (countReverse % 2 == 0) tail.push_back(C);
                else if (countReverse % 2 == 1) head.push_front(C);
            }
        }
    }
    if (countReverse % 2 == 1)
    {
        reverse(ALL(S));
        reverse(ALL(head));
        reverse(ALL(tail));
        deque<char> tempDeq = head;
        head = tail;
        tail = tempDeq;
    }
    REPV(it, head) cout << *it;
    cout << S;
    REPV(it, tail) cout << *it;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
 
const int N = 110;

int get(int n, int i){
    if(n == 1)
        return 1;
    int d = 0;
    while((1 << (d+1)) < n)
        d ++;
    int nl = n - (1 << d);
    if(i >= nl && i < n-nl)
        return 0;
    if(i < nl)
        return get(nl, i);
    return get(nl, i - n + nl);
}

int solve(vector<int> v){
    int n = v.size();
    int ans = 0;
    for(int i=0 ; i<n ; i++){
        ans += get(n, i) * v[i];
        ans %= 2;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;cin >> n;
    string s;cin >> s;
    vector<int> v;
    for(int i=0 ; i<n-1 ; i++)
        v.push_back(abs(s[i] - s[i+1]));
    n = v.size();
    bool two=false, one=false;
    for(int i=0 ; i<n ; i++){
        two |= (v[i] == 2);
        one |= (v[i] == 1);
    }
    if(two && !one){
        for(auto &i : v)
            i /= 2;
        cout << solve(v) * 2 << "\n";
        return 0;
    }
    for(auto &i : v)
        i %= 2;
    cout << solve(v) << "\n";
}


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

void solve(){
ll n, res = 0;
ll pref[300500];

map<ll, ll> m;

cin >> n;
pref[0] = 0;
for(int i=1;i<=n;i++){
	ll x;
	cin >> x;
	pref[i] = pref[i - 1] + x;
}
sort(pref, pref + n + 1);

for(int i=0;i<=n;i++){
  res += m[pref[i]];
m[pref[i]]++;

}
cout << res;
}

int main(){

solve();

return 0;
}

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

int main(){

	int m, f, b;
	cin >> m >> f >> b;

	// 本を購入できないとき
	if (b > m + f) cout << "NA" << endl;
	// 本を購入できるとき
	else if(b <= m) cout << 0 << endl;  // 自分で購入するとき
	else cout << b - m  << endl;  // 友達から借りたとき

	return 0;
}


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

int main () {
  string S;
  cin >> S;
  
  vector<char> data = {S.at(0),S.at(1),S.at(2)};
  int count = 0;
  for (int x : data) {
    if (x == 'o') {
      count ++;
    }
  }
  cout << 700+100*count << endl;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,q; cin >> n >> q;
  vector<vector<int>> G(n);
  REP(i,n-1){
    int a,b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<ll> ans(n, 0);
  REP(i,q){
    int p,x; cin >> p >> x;
    p--;
    ans[p] += x;
  }
  
  vector<bool> seen(n, false);
  queue<int> que;
  que.push(0);
  while(!que.empty()){
    int cur = que.front();
    que.pop();
    seen[cur] = true;
    for(auto next: G[cur]){
      if(seen[next]) continue;
      ans[next] += ans[cur];
      que.push(next);
    }
  }
  
  REP(i,n) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 17340
#include<iostream>
#include <string>
#include <regex>
using namespace std;
int main(){
  string a;
  cin >> a;
  size_t alens = a.length();
  int alen = int(alens);
  int ans = 0;
  for (int i = 0; i < alen+1; ++i){
    for (int k = 0; k < alen+1; ++k){
     string cut = a.substr(i, k);
     int cutlen = int(cut.length());
     //check ATCG
     string cutrep = regex_replace(cut, regex("[ATCG]"), "");
     int cutreplen = int(cutrep.length());
     if (cutreplen == 0){
       if (cutlen >= ans){
        ans = cutlen;
       }
     }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    rep(i, k) {
        if (a + i <= b) {
            v.push_back(a + i);
        }
    }
    rep(i, k) {
        if (a <= b - (k - 1) + i) {
            v.push_back(b - (k - 1) + i);
        }
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    rep(i, v.size()) cout << v[i] << endl;
    return 0;
}

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

a_n = {}
for i in range(n):
    if a[i] not in a_n.keys():
        a_n[a[i]] = 1
    else:
        a_n[a[i]] += 1

if (n-len(a_n.keys()))%2 == 0:
    print(len(a_n.keys()))
else:
    print(len(a_n.keys())-1)


Measured memory_bytes: 18272
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,j,k,n,d,a[15][15];
  vector<int> x(100010,0);
  cin >> n >> d;
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      scanf("%d ",&a[i][j]);
    }
  }
  int ans=0;
  for(i=0;i*i<=100000;i++){
    x[i*i]=1;
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      int len=0;
      for(k=0;k<d;k++){
        len+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      if(x[len]==1){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int n, cnt = 0;
	string s;
	char c;
	cin >> n >> s;
	c = 'A';
	for(int i=0; i<s.length(); i++){
		if(c != s[i]){
			cnt++;
			c = s[i];
		}
	}
	cout << cnt << endl;
	return 0;
}


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


int main(){
    long long X;
    cin >> X;

    long long a=100;

    
    long long count=0;

    for(long long int i=0;i<3761;i++){
       a=a*1.01;
       count++;

       if(X<=a){
           break;
       }
    }
    
  cout << count << endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 100007;
const LD EPS = 1e-7;

string S;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	cin >> S;
	int ans = INF;
	for (char c = 'a'; c <= 'z'; ++c)
	{
		int cur = 0, len = 0;
		REP(i, SZ(S))
		{
			if (S[i] == c)
			{
				cur = max(cur, len);
				len = 0;
			}
			else
				++len;
		}
		cur = max(cur, len);
		ans = min(ans, cur);
	}
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,y,m,d;
int ax,ay,b,c;
int sum;

int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		cin >>y >>m >>d;
		sum=1;
		ax=999/3-y/3;
		ay=(999-y)-ax;
		sum+=ax*200+ay*195;
		b=10-m;
		if(y%3==0){
			sum+=b*20+(20-d);
		}else{
			sum+=(b/2)*39+(b%2)*19;
			if(b%2==0){
				sum+=(19-d);
			}else{
				sum+=(20-d);
			}
		}
		cout <<sum <<endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#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>;

void Main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  ll kokoti = 0;
  if (n==2) {cout << max(a[0], a[1]) << endl; return;}
  for (int i = 0; i <= (n-1)/2; i++) {
    kokoti += a[i];
  }
  if (n%2==0) kokoti += a[(n-1)/2];
  for (int i = (n-1)/2 - 1; i > 0; i--) {
    kokoti += a[i];
  }
  cout << kokoti << endl;
}

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


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
vl v;

void input(void){
cin>>n;
inputv(v,n);
}
void solve(void){
    ll a;
    rep(i,n){
        if(i==0)a=v[0]-1;
        else{
            if(a<v[i]){
                a=v[i]-1;
            }
            else if(a==v[i]){
                a=v[i];
            }
            else{
                cout<<"No"<<endl;
                return;
            }
        }
    }
    cout<<"Yes"<<endl;
    return;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 1400
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var M = cin.ReadInt;
            var xs = new int[M];

            for (int i = 0; i < M; i++)
            {
                xs[i] = cin.ReadInt;
            }
            xs = xs.OrderBy(x => x).ToArray();

            int ret = 0;
            if (M == 1 || M <= N)
            {
                Console.Write(ret);
                return;
            }
            if (N == 1)
            {
                ret = xs[M-1] - xs[0];
                Console.Write(ret);
                return;
            }

            var Ls = new int[M-1];
            for (int i = 0; i < M - 1; i++)
            {
                Ls[i] = (xs[i + 1] - xs[i]);
            }
            Ls = Ls.OrderBy(x => x).ToArray();

            for (int i = 0; i < M-N; i++)
            {
                ret += Ls[i];
            }
            Console.Write(ret);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 25696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
//int 2×10の9乗
 
int main() {
  ll a, b;
  ll c, d;
  cin >> a >> b >> c >> d;
  ll ans=0;
  ll C=b/c, D=b/d, l=c*d/__gcd(c,d), L=b/l;
  ll ansk1=b-(C+D-L);
  ll CC=(a-1)/c, DD=(a-1)/d, LL=(a-1)/l;
  ll ansk2=(a-1)-(CC+DD-LL);
  ans = ansk1 - ansk2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

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

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

	final long MODULO = (long) (1e9 + 7);
	int n;
	int m;
	int[] c;
	int[] l;
	int[] r;

	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		int[] s = new int[n];
		char[] S = sc.next().toCharArray();
		l = new int[m];
		r = new int[n];
		for (int i = 0; i < n; ++i) {
			r[i] = i;
		}
		for (int i = 0; i < n; ++i) {
			s[i] = (S[i] == '0' ? 0 : 1);
		}
		for (int i = 0; i < m; ++i) {
			l[i] = sc.nextInt();
			--l[i];
			r[l[i]] = Math.max(r[l[i]], sc.nextInt() - 1);
		}
		for (int i = 1; i < n; ++i) {
			r[i] = Math.max(r[i - 1], r[i]);
		}
		c = new int[n];
		for (int i = 0; i < n; ++i) {
			c[i] = (i > 0 ? c[i - 1] : 0) + s[i];
		}
		memo = new long[n][n];
		for (int i = 0; i < memo.length; ++i) {
			for (int j = 0; j < memo[i].length; ++j) {
				memo[i][j] = -1;
			}
		}
		System.out.println(f(0, c[r[0]]));
	}

	long[][] memo;

	long f(int l, int curC) {
		if (r[l] - (l - 1) < curC)
			return memo[l][curC] = 0;
		if (l == n - 1) {
			if (curC > 1)
				throw new AssertionError();
			return memo[l][curC] = 1;
		}
		if (memo[l][curC] != -1)
			return memo[l][curC];
		long ret = 0;
		if (!(r[l] - (l - 1 + 1) < curC)) {
			ret += f(l + 1, curC + c[r[l + 1]] - c[r[l]]);
		}
		if (!(curC == 0)) {
			ret += f(l + 1, curC - 1 + c[r[l + 1]] - c[r[l]]);
		}
		ret %= MODULO;
		return memo[l][curC] = ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 128224
mod=10**9+7
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[(m+1)*[1]for _ in range(n+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]
    else:dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]
    dp[i+1][j+1]%=mod
print(dp[-1][-1])

Measured memory_bytes: 72668
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scanner =new Scanner(System.in);
		
		
		while(true){
			int x=scanner.nextInt();
			int y=scanner.nextInt();
			if(x==0 && y==0){
				break;
			}
			System.out.println(Math.min(x,y)+" "+Math.max(x,y));
		}
	}
}


Measured memory_bytes: 34936
#include <bits/stdc++.h>
using namespace std ;
const int N=1e6+5 ;
int n ,  x  , t[N],freq[26];


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

 int x=a-b ;
 if (x-c>=0)
    cout<<0 ;
    else
        cout<<c-x ;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import product, permutations, combinations

H=2
W=int(input())
candies = [list(map(int, input().split())) for i in range(H)]

count = [0 for i in range(W)]

for p in range(W):
    count[p] = sum(candies[0][0:p+1]) + sum(candies[1][p:W+1])
print(max(count))



Measured memory_bytes: 3060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int t = cin.ReadInt;
            int a = cin.ReadInt;
            int[] h = cin.ReadIntArray(n);

            int result = 0;
            double diff = 100000;

            for (int i = 0; i < n; i++)
            {
                double temp = Math.Abs(a - calcTemp(t, h[i]));
                if (temp < diff)
                {
                    diff = temp;
                    result = i + 1;
                }
            }

            Console.WriteLine(result);
        }

        public double calcTemp(int temp, int high)
        {
            return temp - (double)high * 0.006;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11280
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

int dp[2001][2001][2];
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, M; cin >> N >> M;
	string a, b; cin >> a >> b;
	//reverse(a.begin(), a.end());
	//reverse(b.begin(), b.end());
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= 2000; ++i) {
		for (int j = 0; j <= 2000; ++j) {
			dp[i][j][1] = 0;
			dp[i][j][0] = -1e9;
		}
	}
	int ans = 0;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) {
			for (int k = 0; k < 2; ++k) {
				if (i != N) {
					if ((a[i] == 'I') == k) {
						dp[i + 1][j][!k] = max(dp[i + 1][j][!k], dp[i][j][k] + 1);
					}
				}
				if (j != M) {
					if ((b[j] == 'I') == k) {
						dp[i][j + 1][!k] = max(dp[i][j + 1][!k], dp[i][j][k] + 1);
					}
				}
			}
			ans = max(ans, dp[i][j][0]);
		}
	}
	if (ans&&ans % 2 == 0) {
		ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34516
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long
#define INF 1000000000

int main() {
    ll h, w; cin >> h >> w;
    ll ans = INF;
    for(ll i=1; i<h+1; i++) {
        ll a = h-i;
        // 垂直方向に分割
        ll b = w/2;
        ll sa = w*i;
        ll sb = a*b;
        ll sc = a*(w-b);
        ll max_s = max(sa, max(sb, sc));
        ll min_s = min(sa, min(sb, sc));
        ans = min(ans, (max_s-min_s));
        // 水平方向に分割
        b = a/2;
        sb = w*b;
        sc = w*(a-b);
        max_s = max(sa, max(sb, sc));
        min_s = min(sa, min(sb, sc));
        ans = min(ans, (max_s-min_s));
    }
    for(ll i=1; i<w+1; i++) {
        ll a = w-i;
        // 垂直方向に分割
        ll b = h/2;
        ll sa = h*i;
        ll sb = a*b;
        ll sc = a*(h-b);
        ll max_s = max(sa, max(sb, sc));
        ll min_s = min(sa, min(sb, sc));
        ans = min(ans, (max_s-min_s));
        // 水平方向に分割
        b = a/2;
        sb = h*b;
        sc = h*(a-b);
        max_s = max(sa, max(sb, sc));
        min_s = min(sa, min(sb, sc));
        ans = min(ans, (max_s-min_s));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

x = input()

a = 0
z = 0

for i in range(len(x)):
    if x[i] == "A":
        a = i
        break

for i in range(len(x)):
    if x[-(i+1)] == "Z":
        z = len(x) - i
        break

print(len(x[a:z]))


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#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)
constexpr int MOD = 1000000007;
int main()
{
    string S;
    cin >> S;
    int now = 1;
    int right = 0;
    int n = S.size() + 1;
    vector<int> ans(n, 0);
    REP(i, n) {
        if(i != n && S[i] == '>') {
            if(right == 0) now--;
            right++;
        } else {
            if(right != 0) {
                FOR(j, now, i+1) {
                    if(ans[j] < i-j) ans[j] = i-j;
                }   
            }
            
            now = i+2;
            right = 0;
            if(i != n-1) {
                ans[i+1] = ans[i]+1;
            }
        }
    }
    lint sum = 0;
    //REP(i, n) cout << ans[i] << (i!=n-1 ? " " : "");
    //cout << endl;
    REP(i, n) {
        sum += (lint)ans[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2820
using System;
class Program
{
    static void Main(string[] args)
    {
        string s = ReadStr();
        long m = 999;
        for(int i = 0; i < s.Length - 2; i++)
        {
            int t = int.Parse(clip(s, i, 3)) - 753;
            m = (abs(t) < m ? abs(t) : m);
        }
        Write(m);
    }

    static void Write(string s) { Console.WriteLine(s); return; }
    static void Write(long n) { Console.WriteLine(n.ToString()); return; }
    static string ReadStr() { return Console.ReadLine(); }
    static string[] ReadStrs() { return Console.ReadLine().Split(' '); }
    static long Read() { return long.Parse(Console.ReadLine()); }
    static long[] Read(long n)
    {
        long[] p = new long[n];
        string[] t = Console.ReadLine().Split(' ');
        for(long i = 0; i < n; i++) { p[i] = long.Parse(t[i]); }
        return p;
    }
    static long abs(long n) { return (n > 0) ? n : -n; }
    static long gcd(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
    static long gcd(long a, long b) { return (a==0)?b:gcd(b % a, a); }
    static long lcm(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
    static long lcm(long a, long b) { return a * b / gcd(a, b); }
    static long max(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p>n[i])?p:n[i]; } return p; }
    static long min(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p<n[i])?p:n[i]; } return p; }
    static void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    static void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    static void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
    static string clip(string s, int start, int count)
    {
        if (start + count < s.Length) { s = s.Remove(start + count); }
        if (start > 0) { s = s.Remove(0, start); }
        return s;
    }
}


Measured memory_bytes: 11092
Bingo = [[0,0,0],[0,0,0],[0,0,0]]
Bingo[0][0],Bingo[0][1],Bingo[0][2]= map(int, input().split())  
Bingo[1][0],Bingo[1][1],Bingo[1][2]= map(int, input().split()) 
Bingo[2][0],Bingo[2][1],Bingo[2][2]= map(int, input().split()) 
N = int(input())
Numbers = [int(input() )for _ in range(N)]

#判定用
maru =[[0,0,0],[0,0,0],[0,0,0]]
Flag =0


for Number in Numbers:
  for i in range(3):
    for j in range(3):
      if Bingo[i][j] == Number:
        maru[i][j]=1

for i in range(3):
  if maru[0][i] ==1 and maru[1][i]== 1 and maru[2][i] ==1:
    Flag = 1
    break
    
  if maru[i][0] ==1 and maru[i][1]== 1 and maru[i][2] ==1:
    Flag = 1
    break

  if maru[0][0] ==1 and maru[1][1]== 1 and maru[2][2]==1:
    Flag = 1
    break

  if maru[0][2] ==1 and maru[1][1]== 1 and maru[2][0]==1:
    Flag = 1
    break

if Flag == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
vector<int> X,Y;
vector<char> D;

double calc(double t) {
    double xmax,xmin,ymax,ymin;
    xmax = -TEN(8);
    xmin = TEN(8);
    ymax = -TEN(8);
    ymin = TEN(8);

    for(int i = 0;i < N;i++) {
        double dx=X[i];
        double dy=Y[i];

        if(D[i] == 'U') {
            dy += t;
        } else if(D[i] == 'D') {
            dy -= t;
        } else if(D[i] == 'L') {
            dx -= t;
        } else {
            dx += t;
        }

        xmax = max(xmax,dx);
        xmin = min(xmin,dx);
        ymax = max(ymax,dy);
        ymin = min(ymin,dy);
    }

    return (xmax-xmin)*(ymax-ymin);
}

double solve(int t) {
    double ll = 0;
    double lr = t;
    double area = calc(0);
    int cur = 0;
    while(cur++ < 500) {
        double l = ll+(lr-ll)/3.0;
        double r = l+(lr-ll)/3.0;

        double f1 = calc(l);
        double f2 = calc(r);
        if(f1 < f2) {
            lr = r;
        } else if(f1 > f2) {
            ll = l;
        } else {
            ll = l;
        }

        area = min(area,min(f1,f2));
    }

    return area;
}

int main(void) {
    cin>>N;

    int m = 0;
    for(int i = 0;i < N;i++) {
        int x,y;
        char d;
        cin>>x>>y>>d;
        X.push_back(x);
        Y.push_back(y);
        D.push_back(d);
        m = max(m,max(abs(x),abs(y)));
    }

    printf("%.10f\n",solve(2*m));

    return 0;
}


Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp65 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = st[0];
            int A = st[1];
            int B = st[2];

            int ans = 0;

            for (int k = 1; k <= N; k++) {
                int keta = k.ToString().Length;
                int sum = 0;

                for (int i = 0; i < keta; i++) {
                    sum += int.Parse(k.ToString()[i].ToString());

                }

                if (A <= sum && sum <= B) {
                    //Console.WriteLine(k);
                    ans += k;
                }

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15316
main = do
  getLine
  as<-map read.words<$>getLine
  print $ solve as

solve as
  | even negs = sum asabs
  | elem 0 as = sum asabs
  | otherwise = sum asabs - 2 * minimum asabs
  where
  asabs = map abs as
  negs = length $ filter (<0) as

Measured memory_bytes: 39548
#include <bits/stdc++.h>
using namespace std;
int main()
{
    set<string> SET;
    int n;
    string str;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        cin >> str;
        SET.insert(str);
    }
    printf("%d\n", SET.size());
}


Measured memory_bytes: 19380
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;
 
template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}
 
template<typename F>
inline void write(F x)
{
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar('\n');
}
 
template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }
 
template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }
 
const int P = 998244353;
ll fpw(ll x, ll mi) {
	ll res = 1;
	for (; mi; mi >>= 1, x = x * x % P) 
		if (mi & 1) res = res * x % P;
	return res;
}
 
const int N = 1005000;
ll jie[N], inv[N];
inline ll C (ll n, ll m) {
	return jie[n] * inv[m] % P * inv[n-m] % P;
}
 
int m, n;
int main() {
	read(n), read(m);
	int lim = n + m; jie[0] = inv[0] = inv[1] = 1;
	for (int i = 2;i <= lim; i++)
		inv[i] = (ll)(P - P / i) * inv[P % i] % P;
	for (int i = 1; i <= lim; i++)
		inv[i] = inv[i - 1] * inv[i] % P, jie[i] = jie[i-1] * i % P;
	ll ans = 0;
	for (int i = 1;i <= min(n, m); i++)
		ans = (ans + C(2 * i, i) * C(n + m - 2 * i, n - i)) % P;
	ans = ans * fpw(C(n + m, n) * 2 % P, P - 2);
	write((max(n, m) + ans) % P);
	return 0;
}

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

int main()
{
    char a[105],p[105];
    scanf("%s",a);
    int i,l,j=0;
    l=strlen(a);
    /*
    int i,l,f,j=1;


    strcpy(p,a);

    if(strcmp(a,strrev(p))==0) printf("0");
    else
    {
        i=0,f=l;
        while(strcmp(a,strrev(p))==0)
            {
                if(a[i]!=a[f-1])
                {
                    j+=1;
                    a[i]=a[f-1];
                    strrev(p);
                    i++,f--;
                }

            }

        printf("%d",j);
    }
    l=0;
    */
    for(i=0;i<l/2;i++)
    {
        if(a[i]!=a[l-i-1]) j+=1;
    }

    printf("%d",j);
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

def gcd(a,b):
    if(b==0):
        return a
    return gcd(b, a%b)

def lcm(a,b):
    return (a * b)//gcd(a, b)

def main(N,T):
    ans = 1
    for t in T:
        ans = lcm(ans, t)
        
    print(ans)

if __name__ == '__main__':
    N = int(input())
    T = []
    for i in range(N):
        T.append(int(input()))
    main(N,T)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = 0;
    for(int i = 1;i < 10 ;i++){
      for(int j = 1;j < 10 ;j++){
        b = i * j;
        if(a == b){
          System.out.println("Yes");
          System.exit(0);
        }
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;
const int INF = 1e9;
#define ll long long

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		for(int i = 0; i < 5; i++){
			int x;
			cin >> x;
			if(x == 0){
				cout << i+1 << endl;
				return;
			}
		}

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3548
//*--  ILSH  --*//
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define sz size 
#define se second 
#define len length
const int N=2e5+5;
const ll inf=1e18+1e17;
void solve(){
	int n;
	cin>>n;
	int arr[n];
	for ( int i=0;i<n;i++)
		cin>>arr[i];
	sort( arr,arr+n);
	if ( n%2||(arr[n/2]==arr[n/2-1])){
		cout<<0<<'\n';
		return;
	}
	cout<<arr[n/2]-arr[n/2-1]<<'\n';


}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while ( t-- ){
    	solve();
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){

	string str;
	cin>>str;

	if(str.at(5)=='0'){
		if(str.at(6)-'0'>4){
			cout<<"TBD"<<endl;
		}
		else{
			cout<<"Heisei"<<endl;
		}
	}
	else{
		cout<<"TBD"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <math.h>
#include <algorithm>

using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;


#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define tasu(x, y) (x+y)%MOD
#define kake(x, y) x*y%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n);
}

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


	long long xyz [3][1010];

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

	long long res = 0;
	for (int bit = 0; bit < (1<<3); ++bit){

		vector<long long> v;

		for(int i=0; i<N; ++i){

			long long temp = 0;

			for (int j = 0; j < 3; ++j){
				if(bit & (1 << j)){
					temp += xyz[j][i];
				} else {
					temp -= xyz[j][i];
				}
			}
			v.push_back(temp);
		}

		sort(v.begin(), v.end(), greater<long long>());

		long long sum = 0;
		for (int i = 0; i < M; ++i){
			sum += v[i];
		}

		res = max(res, sum);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
dp=[[10**9]*(2**n) for i in range(m+1)]
for i in range(m+1):
  dp[i][0]=0
for i in range(1,m+1):
  a,b=map(int,input().split())
  C=list(map(int,input().split()))
  c=0
  for j in range(b):
    c=c+2**(C[j]-1)
  for j in range(2**n):
    dp[i][j]=min(dp[i-1][j],dp[i][j])
    dp[i][j|c]=min(dp[i-1][j]+a,dp[i-1][j|c],dp[i][j|c])
if dp[-1][-1]==10**9:
  print(-1)
else:
  print(dp[-1][-1])

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, x, y;
    cin >> n;
    x = n * 800;
    y = n / 15 * 200;
    cout << x - y << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    int n;
    int count=0;
    int mini=INF;

    cin>>n;
    vector<int> p(n+1);
    FOR(i,1,n){
        cin>>p[i];
    }
    FOR(i,1,n){
        if(p[i]<=mini){
            count++;
        }
        mini=min(mini,p[i]);
    }

    cout<<count<<endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int cnt=0;
			for(int i=1;i<n;i++)
			{
				int sum=0;
				for(int j=i;j<n;j++)
				{
					sum+=j;
					if(sum>n)
						break;
					if(sum==n)
						cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 11000
n = int(input())
s = input()
flag = 0
ans = 0
for i,v in enumerate(s):
    if i == 0:
        temp = v   
    else:
        if v != temp:
            if flag == 0:
                ans += 1
                flag = 1
            elif flag == 1:
                flag = 0
        else:
            if flag == 1:
                flag = 0
        temp = v

print(ans)


Measured memory_bytes: 5788