akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    vector<int>v;
    while(n>0){
        int rem=n%10;
        v.push_back(rem);
        n=n/10;
    }
    int f=0;
    for(int i=0;i<v.size();i++){
        if(v[i]==9){
            f=1;
            break;
        }
    }
    if(f==1)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int satu = inpt[0];
        int total = inpt[1];
        GetAns(0, satu, total);
        Console.WriteLine(string.Join(" ", ans));
    }


    int[] satuList = new int[] { 10000, 5000, 1000 };
    int[] ans = new int[3]{-1,-1,-1};
    private bool GetAns(int idx, int remainSatu, int remainTotal) {
        if(idx==satuList.Length-1) {
            if(remainSatu*satuList[idx] == remainTotal) {
                ans[idx] = remainSatu;
                return true;
            } else {
                return false;
            }
        }

        for (int i = 0; i <= Math.Min(remainTotal / satuList[idx], remainSatu); i++) {
            bool ret = GetAns(idx + 1, remainSatu - i, remainTotal - satuList[idx] * i);
            if(ret) {
                ans[idx] = i;
                return true;
            }
        }
        return false;
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



2000 20000000

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B;
    cin >> A >> B;
    if (B % A == 0)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>

#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

int main(){
    int n,sum,ans=0;
    cin >> n;
    vector<int>vec(n);

    rep(i,n){
        cin >> vec[i];
    }

    rep(i,n){
        ans+=vec[i]-1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 10000
#define NIL -1
struct node{int p,l,r;};
struct node T[MAX];
int n;
void preParse(int u)
{
    if(u==NIL)
        return ;
    cout<<" "<<u;
    preParse(T[u].l);
    preParse(T[u].r);
}
void inParse(int u)
{
    if(u==NIL)
        return ;
    inParse(T[u].l);
    cout<<" "<<u;
    inParse(T[u].r);
}
void postParse(int u)
{
    if(u==NIL)
        return ;
    postParse(T[u].l);
    postParse(T[u].r);
    cout<<" "<<u;
}
int main()
{
    int i,v,l,r,root;
    cin>>n;
    for(i=0;i<n;i++)
        T[i].p=NIL;
    for(i=0;i<n;i++)
    {
        cin>>v>>l>>r;
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL)  T[l].p=v;
        if(r!=NIL)  T[r].p=v;
    }
    for(i=0;i<n;i++)
        if(T[i].p==NIL)
            root=i;
    cout<<"Preorder"<<endl;
    preParse(root);
    cout<<endl;
    cout<<"Inorder"<<endl;
    inParse(root);
    cout<<endl;
    cout<<"Postorder"<<endl;
    postParse(root);
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3104
input()
ns = [n for n in input()]
 
scores = 0
first = []
second = []
third = []
third_nums = None
 
for i in range(len(ns) - 2):
  if ns[i] in first:
    continue
  else:
    first.append(ns[i])
  for j in range(i+1, len(ns) - 1):
    if ''.join([ns[i], ns[j]]) in second:
      continue
    else:
      second.append(''.join([ns[i], ns[j]]))
      third_nums = set(ns[j+1:])
      scores += len(third_nums)
      
print(scores)

Measured memory_bytes: 3648
#include<iostream>
#include<string>

using namespace std;

int main() {
 string str;
 cin >> str;


 char s = str[0];
 int ans = 0;
 for(int i = 1; i < str.size(); i++) {
     if(str[i] != s) {
         s = str[i];
         ans++;
     }
 }

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

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

int ret_num(int c[8])
{
    int ret = 0;
    for (int i = 0; i < 8; i++) {
        ret *= 10;
        ret += c[i];
    }
    return ret;
}

int main()
{
    int p[8];

    while (cin >> p[0]) {
        int min_n, min_idx, min_rot;
        int c[8] = {1, 2, 1, 2, 1, 4, 1, 4};
        int c_print[8] = {1, 2, 1, 2, 1, 4, 1, 4};

        min_n = 100000;
        min_idx = min_rot = 99999999;
        for (int i = 1; i < 8; i++)
            cin >> p[i];

        for (int i = 0; i < 8; i++) {
            int tmp = 0;
            int c_tmp = ret_num(c);

            for (int j  = 0; j < 8; j++)
                tmp += p[j] - min(c[j], p[j]);

            if (tmp < min_n || (tmp == min_n && min_rot > c_tmp)) {
                min_idx = i;
                min_n = tmp;
                min_rot = c_tmp;
            }
                
            rotate(c, c + 1, c + 8);
        }

        for (int i = 0; i < 8; i++)
            cout << c_print[(i + min_idx) % 8] << (i == 7 ? '\n' : ' ');
    }

    return 0;
}

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll mod = 1e9 + 7;
    ll ans = 0;
    for (ll k = K; k <= N + 1; k++) {
        ll low = k * (k - 1) / 2;
        ll high = (N * (N + 1) - (N - k) * (N - k + 1)) / 2;
        ans = (ans + high - low + 1) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string s;
  cin >> s;
  LL n = s.length();
  LL dist = 0;
  LL pos = 0;
  REP(i, 0, n) {
    if (s[i] == 'W') {
      dist += (i-pos);
      pos+=1;
    }
  }
  cout<<dist<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  int mx = 0, mn = n;
  REP(i, n) {
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  if (mx == mn) {
    REP(i, n) {
      if (a[i] != n - 1 && 2 * a[i] > n) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else if (mx - mn == 1) {
    int y = 0;
    REP(i, n) {
      if (a[i] == mx) y++;
    }
    int x = n - y;
    if (x < mx && 2 * (mx - x) <= y) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int[] list = new int[5];
		Scanner sc = new Scanner(System.in);
		list[0] = sc.nextInt();
		list[1] = sc.nextInt();
		list[2] = sc.nextInt();
		list[3] = sc.nextInt();
		list[4] = sc.nextInt();
		int k = sc.nextInt();
      
		String result = "Yay!";
		boolean error = false;
		
		for(int i=0;i<list.length;i++) {
			for(int j=i+1;j<list.length;j++) {
				if(list[j]-list[i] > k) {
					result = ":(";
					error = true;
					break;
				}
			}
			if(error) break;
		}
		
		System.out.println(result);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+5;
vector<pair<ll,ll> >v(N);//vector对pair排序时按'键'排序 即第一元素first 
ll dp[N][N];
int n;
ll fun(int l,int r){
	if(l>r) return 0;
	if(dp[l][r]) return dp[l][r];
	int i=n-(r-l+1);//当前要放入的数的下标 
	return dp[l][r]=max(fun(l,r-1)+v[i].first*(r-v[i].second),fun(l+1,r)+v[i].first*(v[i].second-l));//放两端取最大 
}
int main(){
	scanf("%d",&n);
	for(int i=0,x;i<n;i++)
		scanf("%d",&x),v.push_back({x,i});
	sort(v.rbegin(),v.rend());//贪心从大到小排 
	fun(0,n-1);
	printf("%lld\n",dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 26544
#include <stdio.h>
#include <inttypes.h>

uint64_t gcd(uint64_t a, uint64_t b) {
	while (b > 0) {
		uint64_t r = a % b;
		a = b;
		b = r;
	}
	return a;
}

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

int main(void) {
	uint64_t N;
	if (scanf("%" SCNu64, &N) != 1) return 1;
	printf("%" PRIu64 "\n", lcm(2, N));
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <set>
 
using namespace std;
 
int main(){
    int a[100000],n,m;
 
    scanf("%d %d" ,&n ,&m);
    for(int i = 0 ; i < n ; i++){
	scanf("%d" ,&a[i]);
    }
 
    set<int> st;
    int cnt = 0;
    for(int i = n-1 ; i >= 0 ; i--){
	if(cnt == m) break;
	if(!st.count(a[i])){
	    cnt++;
	    st.insert(a[i]);
	    printf("%d\n" ,a[i]);
	}
    }
    return 0;
}

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

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

    if ((abs(a+b)%2) != 0) cout << "IMPOSSIBLE" << endl;
    else if (abs(a+b)%2 == 0) cout << abs(a+b)/2 << endl;

    return 0;
}

Measured memory_bytes: 3564
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
	int n;
	while (cin >> n, n) {
		int seconds_in_a_day = 24 * 60 * 60 + 60 * 60 + 60;
		vi train(seconds_in_a_day, 0);
		REP(i, n) {
			int h, m, s; scanf("%d:%d:%d", &h, &m, &s);
			int departure_time = (h * 60 * 60) + (m * 60) + s;
			scanf("%d:%d:%d", &h, &m, &s);
			int arrival_time = (h * 60 * 60) + (m * 60) + s;
			FOR(t, departure_time, arrival_time) {
				++train[t];
			}
		}
		int ans = 0;
		REP(t, seconds_in_a_day) {
			ans = max(ans, train[t]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1592
#include<stdio.h>
#include<string.h>
int main(){
	char a[1009];
	scanf("%s",a);
	int t = strlen(a);
	if(t>26){
		printf("no\n");
	}
	else{
		int b[30];
		for(int i = 0;i<=27;i++){
			b[i]=0;
		}
		for(int i = 0;i<t;i++){
			int y = a[i]-97;
			b[y]++;
		}
		int p = 0;
		for(int i = 0;i<26;i++){
		//	printf("%d\n",b[i]);
			if(b[i]!=1&&b[i]!=0){
				p=1;
			}
		}
		if(p==1){
			printf("no\n");
		}	
		else printf("yes\n");
	} 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l;
pair <long long,long long> A[200005];
long long B[200005],maxx;
string s;
int main() {
           cin>>s;
           for(long long i=0;i<s.size()/2;i++) {
                      if(s[i]!=s[s.size()-1-i]) { l=1; break; }
           }
           if(l==1) { cout<<"No"; return 0; }
           a=s.size()/2;
           a/=2;
           for(long long i=0;i<a;i++) {
                      if(s[i]!=s[s.size()/2-i-1]) { l=1; break; }
           }
           if(l==1) { cout<<"No"; return 0; }
           cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
#include <deque>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int N, M, x, y, s, l;
  cin >> N >> M;
  int V[N];
  vector<int> E[N], T;
  deque<int> S;
  for (int i = 0; i < N; ++i) {
    V[i] = 0;
  }
  for (int i = 0; i < M; ++i) {
    cin >> x >> y;
    x--; y--;
    E[x].push_back(y);
    V[y] += 1;
  }
  for (int i = 0; i < N; ++i) {
    if (V[i] == 0) {
      S.push_back(i);
    }
  }

  while (S.size()) {
    s = S[0];
    S.pop_front();
    T.push_back(s);
    l = E[s].size();
    for (int i = 0; i < l; ++i) {
      V[E[s][i]]--;
      if (V[E[s][i]] == 0) {
        S.push_back(E[s][i]);
      }
    }
  }
  int ANS[N];
  for (int i = 0; i < N; ++i) {
    ANS[i] = 0;
  }
  int v, t;
  for (int i = 0; i < N; ++i) {
    v = T[i];
    t = ANS[v] + 1;
    l = E[v].size();
    for (int j = 0; j < l; ++j) {
      if (t > ANS[E[v][j]]) {
        ANS[E[v][j]] = t;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (ans < ANS[i]) {
      ans = ANS[i];
    }
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;
#define rep(x, n)          for (int x = 0; x < n; x++)
#define REP(x, a, b)       for (int x = a; x <= b; x++)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define dmp(...) 0
#endif
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double ans=0;
    double omegaa=360.0/(12.0*60.0);
    double omegab=360.0/(60.0);
    double theta=fabs((h*60+m)*omegaa-(h*60+m)*omegab)*2*(3.14159265359)/360.0;
    ans=sqrt(a*a+b*b-2*a*b*cos(theta));
    cout<<fixed;
    cout<<ans<<'\n';
    return 0;
}

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

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

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

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

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

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

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	string s, ans;
	ll k;
	std::cin >> s >> k;

	rep(i, 0, s.size()) {
			ll tmp = 26 - s[i] + 'a';
			if (s[i] != 'a' && k >= tmp) {
				ans += 'a';
				k -= tmp;
			}
			else {
				ans += s[i];
			}
	}

	if (k > 0) {
		k %= 26;
		ans[ans.size() - 1] += k;
		if (ans[ans.size() - 1] > 'z') {
			ans[ans.size() - 1] -= 'a' - 1;
		}
	}
	outn(ans);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#define rep(a,b) for(int i=a;i<b;i++)
typedef long long ll;
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> temp(n,0);
    rep(0,n){
        cin>>temp[i];

    }
    sort(temp.begin(),temp.end());
    ll res=0;
    for(int i=0;i<=n-1-k;i++)
    {
        res=(ll)(res+temp[i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
bool p (vector <long long> health, int a, int b, long long tr) {
	int n = (int)health.size();
	long long sum = tr * (a-b);
	for (int i = 0; i < n; i++) 
		health[i] -= tr*b; 
	for (int i = 0; i < n; i++) {
		if (health[i] > 0) {
			sum -= (a-b) * ceil((double)health[i]/(a-b));
		}
	}
	if (sum < 0)
		return false;
	else
		return true;
}
int binary_search (vector <long long> &health, int left, int right, int a, int b) {
	if (left > right)
		return -1;
	if (left == right) {
		if (p(health, a, b, left))
			return left;
		else
			return -1;
	}
	if ((left+1) == right) {
		if (p(health, a, b, left))
			return left;
		else if (p(health, a, b, right))
			return right;
		else
			return -1;
	}
	int mid = (left+right)/2;
	if (p(health, a, b, mid)) 
		return binary_search(health, left, mid, a, b);
	else
		return binary_search(health, mid, right, a, b);
}


int main (void) {
	long long n, a, b; cin >> n >> a >> b;
	vector <long long> health(n);
	for (int i = 0; i < n; i++)
		cin >> health[i];
	sort(health.rbegin(), health.rend());
	int r = (health[0]/b)+1;
	int l = 0;
	cout << binary_search(health, l, r, a, b) << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = Console.ReadLine().ToCharArray();

        if(N[N.Length - 1] == '3')
        {
            Console.WriteLine("bon");
        }
        else if(N[N.Length - 1] == '0' || N[N.Length - 1] == '1' || N[N.Length - 1] == '6' || N[N.Length - 1] == '8')
        {
            Console.WriteLine("pon");
        }
        else
        {
            Console.WriteLine("hon");
        }

        Console.ReadLine();
    }



}



Measured memory_bytes: 17328
n, d = gets.split.map(&:to_i)
a = $<.map(&:to_i).sort
b = [a.pop]
s = 1 
until a.empty?
    b.shift while b[0] && b[0] - a[-1] > d 
    s = (s + s * b.size) % 1_000_000_007  
    b << a.pop
end
p s

Measured memory_bytes: 11216
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n;
int a[100005],b[100005],c[100005];

int main()
{
	while (scanf ("%d",&n)!=EOF){
		for(int i=1;i<=n;i++){
			scanf ("%d",&a[i]);
			b[i]=c[i]=a[i];
		}
		int ans=0;
		int tmp=0;
		for (int i=1;i<=n;i++){
			if (i==b[i]){
				swap(b[i],b[i+1]);
				tmp++;
			}
		}
		ans=tmp;
	//	printf ("ans_%d\n",ans);
		tmp=0;
		for (int i=n;i>=1;i--){
			if (i==c[i]){
				swap(c[i],c[i-1]);
				tmp++;
			}
		}
	//	printf ("tmp_%d\n",tmp);
		ans=min(ans,tmp);
		printf ("%d\n",ans);
	}
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,p;
  ll n,k; cin>>n>>k;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  ll d;
  bool judge = true;
  //cout<<<<endl;

  int a[k+2][2*k+2];
  for(i=0;i<k+2;i++){
    for(j=0;j<2*k+2;j++) a[i][j]=0;
  }
  ll la,ra,b;
  vector<ll> x(n),y(n);
  vector<char> c(n);
  for(i=0;i<n;i++){
  cin>>x[i]>>y[i]>>c[i];
  }
  for(i=0;i<n;i++){
    c[i]=='W'?d=1:d=-1;
    x[i]%=2*k;y[i]%=2*k;
    if(y[i]>=k){
      y[i]-=k;d*=-1;
    }
    la=(2*k-x[i])%(2*k);
    ra=(3*k-x[i])%(2*k);
    if(d==-1) swap(la,ra);
    b=(k-y[i])%(k);
    if(b==0)b=k;
    //cout<<endl;
    //cout<<b spa la spa ra <<endl;
    a[0][la]++;
    a[b][la]--;
    if(la>k){a[0][0]++;a[b][0]--;}
    if(ra!=0){a[0][ra]--;a[b][ra]++;}
    swap(la,ra);
    a[b][la]++;
    if(la>k){a[b][0]++;}
    if(ra!=0)a[b][ra]--;
    /*for(p=0;p<k;p++){
    for(j=0;j<2*k;j++) cout<<a[p][j]<<" ";//chmax(result,a[i][j]);
    cout << endl;
    }*/
  }
  
  
  /*for(i=0;i<k;i++){
    for(j=0;j<2*k;j++) cout<<a[i][j];//chmax(result,a[i][j]);
    cout << endl;
  }*/
  
  for(i=0;i<k;i++){
    for(j=1;j<2*k;j++) a[i][j]+=a[i][j-1];
  }
  for(i=0;i<2*k;i++){
    for(j=1;j<k;j++) a[j][i]+=a[j-1][i];
  }
  for(i=0;i<k;i++){
    for(j=0;j<2*k;j++) chmax(result,a[i][j]);
    //cout << endl;
  }
  cout<<result<<endl;
  


  return 0;
}

Measured memory_bytes: 9728
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
//#define mod 13
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
   ll power(ll a,ll b)//a raised to power b
   {  if(b==0)return 1;if(b==1)return a;
       ll c=power(a,b/2);
       c*=c;c%=mod;if(b%2==1)c*=a;c%=mod;
        return c;
   }
   ll mi(ll a)
   {
       return power(a,mod-2);
   }
   vector<vector<ll> > vtree;
   vector<ll> vcolor;
   vector<ll> visited;
    vector<ll> dp;
    ll ans=0;;
   ll aman(ll a)
   {  visited[a]=1;

     ll no=0;vector<ll> vcol;
     for(auto x:vtree[a])
     {
         if(!visited[x])no=aman(x);
         vcol.push_back(no);

     }
     if(vcolor[a]==1)
     { ll pr=1;
        for(auto x:vcol){pr*=x;pr%=mod;   }
        ans+=pr;
        return 1;

     }
     ll send=0;
     for(auto x:vcol)send+=x;return send+1;


   }
   int main()
{  /*ll n;cin>>n;
    vtree.resize(n);
    for(ll i=0;i<n-1;i++)
    {   ll a;cin>>a;
        vtree[i+1].push_back(a);
        vtree[a].push_back(i+1);
    }
     vcolor.resize(n);
    for(ll i=0;i<n;i++)cin>>vcolor[i];

    visited.resize(n,0);
    dp.resize(n);
     for(ll i=0;i<n;i++){if(vcolor[i]==1)aman(i);   }
      cout<<ans;*/
      ll p,q,r;cin>>p>>q>>r;
      cout<<min(p+q,min(q+r,r+p));

    return 0;
 }


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 10000005;
const int K = 25;
int d[N], sz[N], p[N], f[N];
pair < int, int > a[N];

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> d[i];
        a[i] = {d[i], i};
    }
    set < pair < int, int > > s;
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) sz[i] = 1;
    for (int i = 1; i <= n; i++){
        int v = a[i].S;
        auto x = s.lower_bound({d[v], 0});
        while(x != s.end() && (*x).F == d[v]){
            int u = (*x).S;
            p[u] = v;
            f[v] += f[u] + sz[u];
            sz[v] += sz[u];
            x++;
        }
        s.insert({d[v] + sz[v] - (n - sz[v]), v});
    }
    vector < pair < int, int > > ans;
    for (int i = 1; i <= n; i++){
        if (p[i] != 0){
            ans.pb({i, p[i]});
        } else if (f[i] != d[i]){
            cout << -1;
            return 0;
        }
    }
    if (ans.size() != n - 1) cout << -1; else{
        for (auto i: ans){
            cout << i.F << " " << i.S << endl;
        }
    }
}


Measured memory_bytes: 21108
#include <iostream>
using namespace std;
int main(){
	int x,y;
	cin >> x >> y;
	bool flag = false;
	for (int i = x; i>=0; i--){
		if ((i*2+(x-i)*4)==y)
			flag = true;
	}
	if (flag) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n; cin >> n; cout << n * (n + 1) / 2 + 1 << endl);

    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int a[N],b[N];
int s[N];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a[i],&b[i]);
        s[a[i]]++;
        s[b[i]]++;
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(s[i]&1)
            cnt++;
    if(cnt>1)
        puts("NO");
    else
        puts("YES");
}


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

int main() {
    int n, cnt[40]{}, x=0, ans=0;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        x ^= a;
        a = a & -a;
        REP(j,30){
            if((a>>j)&1){
                cnt[j]++;
                break;
            }
        }
    }
    int c = 1;
    for(int i=30;i>=0;i--){
        if(((x>>i)&1)==c){
            if(cnt[i]==0){
                ans = -1;
                break;
            }
            ans++;
            c = (c+1)%2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()
L.append(0)
ans = 0
k = L[0]
cnt = 0
for i in range(N+1):
  if k == L[i]:
    cnt += 1
  else:
    if cnt >= k:
      ans += cnt-k
    else:
      ans += cnt
    cnt = 1
    k = L[i]
print(ans)

Measured memory_bytes: 14692
#include <iostream>

using ll = long long;
int comb(int a, int b)
{
  int ret = 1;

  for (int i = 0; i < b; i++) {
    ret *= a - i;
  }
  for (int i = 0; i < b; i++) {
    ret /= b - i;
  }
  return ret;
}

int main(int argc, char ** argv)
{
  //
  int n, m;
  std::cin >> n >> m;
  if ((n == 0) && (m == 0)) {
    std::printf("%d\n", 0);
  } else if ((n == 1) && (m == 1)) {
    std::printf("%d\n", 0);
  } else {
    int ans = 0;
    if (m > 1) {
      ans = comb(n, 2) + comb(m, 2);
      std::printf("%d\n", ans);
    } else {
      ans = comb(n, 2);
      std::printf("%d\n", ans);
    }
  }
  return 0;
}


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

const int magic = 2500;
const long long inf = 4e18;

bool np[magic];
vector<int> prm;

void sieve() {
	np[0] = np[1] = 1;
	for (int i = 2; i < magic; ++i) if (!np[i]) {
		prm.push_back(i);
		for (int j = i + i; j < magic; j += i) np[j] = 1;
	}
}

int n;
long long a[100005];
map<long long,int> f, was;

void calc(int id) {
	for (int x : prm) {
		long long cub = 1ll * x * x * x;
		if (cub > a[id]) break;
		while (a[id] % cub == 0) a[id] /= cub;
	}
}

long long mul(long long x,long long y) {
	if (x > inf / y) return inf;
	return x * y;
}

long long needMul(long long x) {
	long long ret = 1;
	for (int v : prm) if (x % v == 0) {
		int cnt = 0;
		while (x % v == 0) cnt++, x /= v;
		for (int i = 1; i <= 3 - cnt; ++i) {
			ret = mul(ret, v);
		}
	}
	long long y = sqrt(x);
	if (y * y == x) ret = mul(ret, y);
	else ret = mul(ret, mul(x, x));
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(false);
	sieve();
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i], calc(i);
		f[a[i]]++;
	}
	
	int ans = f.count(1);
	for (int i = 1; i <= n; ++i) if (a[i] != 1 && !was.count(a[i])) {
		long long tmp = needMul(a[i]);
		if (f.count(tmp)) {
			ans += max(f[a[i]], f[tmp]);
			was[tmp] = 1;
		} 
		else {
			ans += f[a[i]];
		}
		was[a[i]] = 1;
	}
	cout << ans << '\n';
}

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

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  
  if (S.at(K - 1) == 'A'){
    S.at(K - 1) = 'a';
  }
  else if (S.at(K - 1) == 'B'){
    S.at(K - 1) = 'b';
  }
  else if (S.at(K - 1) == 'C'){
    S.at(K - 1) = 'c';
  }
  
  cout << S << endl;
}
  

Measured memory_bytes: 256
abcd = input()
for i in range(2**3):
    res = int(abcd[0])
    formula = abcd[0]
    for j in range(3):
        if (i >> j) & 1:
            res += int(abcd[j+1])
            formula += '+'
        else:
            res -= int(abcd[j+1])
            formula += '-'
        formula += abcd[j+1]
    if res == 7:
        print(formula + '=7')
        exit(0)

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrep1(i,n) for(int i=n;i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
	int n;
	cin >> n;
	vl a(3 * n);
	rep(i, 3 * n) {
		cin >> a[i];
	}
	priority_queue<ll> pq;
	vl leftsum(3 * n, -INF), rightsum(3 * n, INF);
	leftsum[n - 1] = 0; rightsum[2 * n - 1] = 0;
	rep(i, n) {
		leftsum[n - 1] += a[i];
		pq.push(-a[i]);
	}
	REP(i, n, 2 * n) {
		leftsum[i] = leftsum[i - 1];
		leftsum[i] += a[i];
		pq.push(-a[i]);
		leftsum[i] += pq.top();
		pq.pop();
	}
	priority_queue<ll> pqr;
	for (int i = 3 * n - 1; i >= 2 * n; i--) {
		rightsum[2 * n - 1] += a[i];
		pqr.push(a[i]);
	}	
	for (int i = 2 * n - 1; i >= n; i--) {
		rightsum[i - 1] = rightsum[i];
		rightsum[i - 1] += a[i];
		pqr.push(a[i]);
		rightsum[i - 1] -= pqr.top();
		pqr.pop();
	}
	ll ans = -INF;
	REP (i, n - 1, 2 * n) {
		chmax(ans, leftsum[i] - rightsum[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 9588
s=gets.chomp
sz=s.size
def isACGT(s)
    a=['A','C','G','T']
    return s.split('').all?{|c|a.include?(c)}
end
ans=0
for i in 0...sz
    for j in 0...sz
        if isACGT(s[i..j])&&s[i..j].size>ans
            
            ans=s[i..j].size
        end
    end
end
puts ans


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, inf = 2e9;
int n, x[N], y[N];
int mx[4];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for(int i=0; i<4; i++) mx[i] = -inf;
	for(int i=1; i<=n; i++) 
	{
		cin >> x[i] >> y[i];
		mx[0] = max(mx[0], x[i]+y[i]);
		mx[1] = max(mx[1], x[i]-y[i]);
		mx[2] = max(mx[2], -x[i]+y[i]);
		mx[3] = max(mx[3], -x[i]-y[i]);
	}
	int ans = 0;
	for(int i=1; i<=n; i++)
	{
		ans = max(ans, x[i]+y[i]+mx[3]);
		ans = max(ans, x[i]-y[i]+mx[2]);
		ans = max(ans, -x[i]+y[i]+mx[1]);
		ans = max(ans, -x[i]-y[i]+mx[0]);
	}
	cout << ans << '\n';
	return 0;
}

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



class list {
public:
    int val;
    list* prev;
    list* next;
};
list* nil;

void initialize()
{
    nil = new list;
    nil->prev = nil;
    nil->next = nil;
}

void insert_(int val)
{
    list* p = new list;
    p->val = val;
    p->prev = nil;
    p->next = nil->next;
    p->next->prev = p;
    p->prev->next = p;
}

list* search(int val)
{
    for (list* p = nil->next; p != nil; p = p->next) {
        if (p->val == val) return p;
    }
    return nil;
}

void delete_(list* p)
{
    if (p == nil) return;
    p->prev->next = p->next;
    p->next->prev = p->prev;
    delete p;
}


void trace()
{
    for (list* p = nil->next; p != nil; p = p->next) {
        cout << p->val;
        if (p->next != nil) {
            cout << " ";
        } else {
            cout << "\n";
        }
    }
}

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

    list* head;

    for (int i = 0; i < n; i++) {
        string command;
        cin >> command;
        if (command == "deleteFirst") {
            delete_(nil->next);
            continue;
        }
        if (command == "deleteLast") {
            delete_(nil->prev);
            continue;
        }
        int val;
        cin >> val;
        if (command == "insert") {
            insert_(val);
        } else {
            delete_(search(val));
        }
    }
    trace();
}

Measured memory_bytes: 34356
#include <iostream>
#define rep(i, a) for(int i = 0; i < a; i++)
using namespace std;
int main() {
    int a;
    cin>>a;
    a%=10;
    if(a==2||a==4||a==5||a==7||a==9) cout<<"hon";
    else if(a==0||a==1||a==6||a==8) cout<<"pon";
    else cout<<"bon";
    return 0;
}

Measured memory_bytes: 3604
while True :
    H,W = map(int,input().split())
    if H == W == 0 : break
    setA = "#"*W
    setB = "#"+"."*(W-2)+"#"
    for i in range(H) :
        if i == 0 or i == H-1 : print(setA)
        else : print(setB)
    print()
    


Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int count = 0;
		for(int i = 0; i < S.length(); i++) {
			if(i % 2 == 0) {
				if(S.substring(i, i+1).equals("R")  || S.substring(i, i+1).equals("U") || S.substring(i, i+1).equals("D")) {
					count++;
				}
			}
			if(i % 2 == 1) {
				if(S.substring(i, i+1).equals("L")  || S.substring(i, i+1).equals("U") || S.substring(i, i+1).equals("D")) {
					count++;
				}
			}
		}
		if(count == S.length()) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));

    cout << (a[0] * a[1]) / 2 << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a, b, c; cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES";
	}
	else { cout << "NO"; }
  
	return 0;
}

Measured memory_bytes: 256
from collections import deque

h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
ch-=1
cw-=1
dh-=1
dw-=1

maze=[list(input()) for i in range(h)]

Q=deque()
Q.append((ch,cw,0))

dx=[1,0,-1,0]
dy=[0,1,0,-1]
ddx=[2,2,2,2,2,-2,-2,-2,-2,-2,1,1,1,1,-1,-1,-1,-1,0,0]
ddy=[-2,-1,0,1,2,-2,-1,0,1,2,2,1,-1,-2,2,1,-1,-2,2,-2]

dp=[[float('inf')]*w for i in range(h)]


while Q:
  p=Q.popleft()
  if p[0]==dh and p[1]==dw:
    print(p[2])
    exit()
  
  for i in range(4):
    nx=p[0]+dx[i]
    ny=p[1]+dy[i]

    if 0<=nx<h and 0<=ny<w and maze[nx][ny]=='.' and p[2]<dp[nx][ny]:
      Q.appendleft((nx,ny,p[2]))
      dp[nx][ny]=p[2]

  for j in range(20):
    nnx=p[0]+ddx[j]
    nny=p[1]+ddy[j]

    if 0<=nnx<h and 0<=nny<w and maze[nnx][nny]=='.' and p[2]+1<dp[nnx][nny]:
      Q.append((nnx,nny,p[2]+1))
      dp[nnx][nny]=p[2]+1


print(-1)


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define LL              long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    int n,w;
    cin >> n >> w;
    pii arr[n+1];
    FOR(i,1,n) cin >> arr[i].ff >> arr[i].ss;
    LL dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 or j==0) dp[i][j]=0;
            else if(j-arr[i].ff>=0) dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i].ff]+arr[i].ss);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[n][w];
}

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

int main(){
    int n;
    cin >> n;
    bool moti[110]={};
    for(int i=0; i<n; i++) {
        int d;
        cin >> d;
        moti[d] = true;
    }
    int cnt = 0;
    for(int i=0; i<105; i++){
        if(moti[i])cnt++;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int a, b, c;
	cin >> a >> b >> c;
	bool unko = false;
	FOR(i, 1, b+1) {
		if (a * i % b == c)unko = true;
	}
	cout << (unko ? "YES" : "NO") << endl;
}



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

Measured memory_bytes: 18624
#include <stdio.h>

int main(){
  char op;
  int a,b;
  do{
	scanf("%d %c %d",&a,&op,&b);
    
    if(op == '+'){
    	printf("%d\n",a+b);
    }else if(op == '-'){
    	printf("%d\n",a-b);
    }else if(op =='*'){
    	printf("%d\n",a*b);
    }else if(op == '/'){
    	printf("%d\n",a/b);
    }else;
    
  }while(op != '?');
  
  return 0;
}


Measured memory_bytes: 2064
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

struct Point{double x, y;};

void koch(int n, Point a, Point b){
    if(n==0) return;

    Point s,t,u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0*a.x + 1.0*b.x) / 3.0;
    s.y = (2.0*a.y + 1.0*b.y) / 3.0;
    t.x = (2.0*b.x + 1.0*a.x) / 3.0;
    t.y = (2.0*b.y + 1.0*a.y) / 3.0;
    u.x = s.x + ( ( t.x - s.x ) * cos(th) - ( t.y - s.y ) * sin(th) );
    u.y = s.y + ( ( t.x - s.x ) * sin(th) + ( t.y - s.y ) * cos(th) );

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int main(int argc, char const *argv[])
{
    Point a,b;
    int n;

    cin >> n;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}

Measured memory_bytes: 3160
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long c = scanner.nextLong();
        long d=c-a-b;
        if(4*a*b<d*d && d>0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 21844
fun main(args: Array<String>) {
    readLine()
    val xs = readLine()!!.split(' ').map { it.toLong() }

    var l = -1000000001L
    var r = 1000000001L

    while ((r - l) >= 3) {
        val m0 = (l * 2 + r) / 3
        val m1 = (l + r * 2) / 3

        if (f(xs, m0) < f(xs, m1)) {
            r = m1
        } else {
            l = m0
        }
    }

    println((0..3).map { f(xs, l + it) }.min())
}

fun f(xs: List<Long>, b: Long): Long {
    return xs.mapIndexed { i, x -> Math.abs(x - (b + i + 1)) }.sum()
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, M;
int ret;
int a[1000010];
int num[100010];
vi vec[100010];

int solve(int p, int q) //p<q
{
	priority_queue<pii> q1, q2;

	map<int,int> m1, m2;
	for (int x:vec[p]) {
		++m1[x];
	}
	for (int x:vec[q]) {
		++m2[x];
	}

	for (const pii pr:m1) {
		q1.push(mp(pr.se & 1, pr.se));
	}

	for (const pii pr:m2) {
		q2.push(mp(pr.se & 1, pr.se));
	}

	int res = 0;

	while (q1.size()>0&&q2.size()>0) {
		pii p1 = q1.top(); q1.pop();
		pii p2 = q2.top(); q2.pop();
		++res;
		p1.fi ^= 1;
		p2.fi ^= 1;
		p1.se--;
		p2.se--;
		if (p1.se) {
			q1.push(p1);
		}
		if (p2.se) {
			q2.push(p2);
		}		
	}

	while (!q1.empty()) {
		pii p1 = q1.top(); q1.pop();
		res += p1.se / 2;
	}

	while (!q2.empty()) {
		pii p2 = q2.top(); q2.pop();
		res += p2.se / 2;
	}

	return res;
}

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

	rep(i, N) {
		int X;
		cin >> X;
		a[i] = X;
		++num[X%M];
		vec[X%M].pb(X);
	}

	ret = num[0]/2;
	if (M%2==0) {
		ret += num[M/2]/2;
	}

	for (int i = 1; i < M; ++i) {
		if (i >= M - i) break;
		ret += solve(i, M-i);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 6528