akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int n=s.size();

    if(s[0] == '0' || s[n-1] == '1'){
        cout << -1 << endl;
        return 0;
    }

    for(int i=0; i<n-1; i++){
        if(s[i] != s[n-i-2]){
            cout << -1 << endl;
            return 0;
        }
    }

    int cur=1;
    for(int i=0; i<n-1; i++){
        cout << cur << " " << i+2 << endl;
        if(s[i] == '1') cur=i+2;
    }
}

Measured memory_bytes: 1664
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,ans;
struct node{ll x,y;}p[maxn];

inline bool cmp(node a,node b)
{
	return atan2(a.y , a.x) < atan2(b.y , b.x);
}

inline ll wk(int x,int y)
{
	ll tx=0,ty=0;
	for(int i=x;i<=y;i++) tx+=p[i].x,ty+=p[i].y;
	return tx*tx+ty*ty;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++) p[i].x=read(),p[i].y=read();
	sort(p+1,p+n+1,cmp);
	//for(int i=1;i<=n;i++) cout<<p[i].x<<" "<<p[i].y<<endl;
	for(int i=1;i<=n;i++) p[i+n]=p[i];
	for(int i=1;i<=n;i++) for(int j=i;j<=i+n-1;j++) ans=max(ans,wk(i,j));
	printf("%.10lf",sqrt(ans));
	return 0;
}

Measured memory_bytes: 512
import sys
import math
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
u=v-w
if u<=0:
  print("NO")
  sys.exit()

t2=abs(b-a)/u
if math.ceil(t2)<=t:
  print("YES")
else:
  print("NO")
  

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


typedef pair<ll,ll> pll;


ll n, d;
ll a[20][20];
bool check(ll D)
{
        ld yo = (ld)sqrt(D);
        ll rr = floor(yo);
        rr -= 2;
        ll cntt = 10;
        while(cntt){
                cntt--;
                if(rr*rr == D) return true;
                rr++;
        }
        return false;
}
bool ok(ll i, ll j)
{
        ll D = 0;
        for(ll x=1;x<=d;x++) D += (a[i][x] - a[j][x])*(a[i][x] - a[j][x]);
        return check(D);
}
int main()
{
        cin >> n >> d;
        for(ll i=1;i<=n;i++) {
                for(ll j=1;j<=d;j++) cin >> a[i][j];
        }
        ll ans = 0;
        for(ll i=1;i<=n;i++){
                for(ll j=i+1;j<=n;j++){
                        if(ok(i,j)) ans++;
                }
        }
        cout << ans << endl;
        return 0;
}


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

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define FOR(x, l, r)            for (int x = l; x<=r; ++x)
#define REP(x,r)                for (int x = 0; x <r; ++x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";

//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//



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

    vector<int> v(2*n);
    for(int i=0;i<2*n;i++)
    {
        cin>>v[i];
    }
    sort(all(v));
    int tot=0;

    for(int i=1;i<v.size();i+=2)
    {
        tot+=min(v[i],v[i-1]);
    }
    cout<<tot;


}


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;

    // '0' - red, '1' - blue
    size_t red = 0, blue = 0;
    for (auto &si: s) {
        if (si == '0') {
            red++;
        } else {
            blue++;
        }
    }

    if (red == blue) {
        cout << s.length() << "\n";
    } else {
        cout << min(red, blue) * 2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int P, Q, R;

		P = scan.nextInt();
		Q = scan.nextInt();
		R = scan.nextInt();

		int[] arr = { P, Q, R };

		//		List<Integer> list = Stream.of(arr).sorted().collect(Collectors.toList());
		int[] ans = Arrays.stream(arr).sorted().toArray();

		int sum;
		sum = ans[0] + ans[1];

		System.out.println(sum);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

int n, m, a[N]; ll tp[N], ts[N];

inline void add(int l, int r, int k, int b) {
	tp[l] += k; tp[r + 1] -= k;
	ts[l] += b; ts[r + 1] -= b;
}

int main() {

	File();

	n = read(); m = read();

	For (i, 1, n) a[i] = read();

	ll cost = 0;
	For (i, 2, n) {
		int l = a[i - 1], r = a[i];
		if (l < r)
			add(l + 1, r, 1, -(l + 1)), cost += r - l;
		else {
			if (l < m) add(l + 1, m, 1, -(l + 1));
			add(1, r, 1, m - l - 1);
			cost += m - (l - r);
		}
	}

	ll ans = 0;
	For (i, 1, m) {
		tp[i] += tp[i - 1];
		ts[i] += ts[i - 1];
		chkmax(ans, i * tp[i] + ts[i]);
	}
	printf ("%lld\n", cost - ans);

	return 0;

}

Measured memory_bytes: 2176
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int compare_ll(const void *a, const void *b)
{
	ll *A = (ll *)a;
	ll *B = (ll *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;//昇順と降順あってる？
	return 0;
}

int main(void)
{
	//変数の宣言
	int n;
	int t[110];
	int v[110];
	double s[40010];
	int ruiseki[110];
	int memo[110];


	//よく使う変数
	int i,j,k,l;
	int flag=0;
	double ans=0;
	int count=0;
	double temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	int dummy;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);


	for(i=0;i<n;i++){
		scanf("%d",&t[i]);
//		scanf_s("%d",&t[i]);
	}

	v[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&v[i]);
//		scanf_s("%d",&v[i]);
	}
	v[n+1]=0;
	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	ruiseki[0]=0;
	for(i=1;i<=n;i++){
		ruiseki[i]=ruiseki[i-1]+t[i-1];
	}


	for(i=0;i<=n;i++){
		for(j=0;j<=ruiseki[n]*2;j++){
			temp=j;
			if(i==0){
				s[j]=min(temp/2,ruiseki[n]-temp/2);
			}else if(temp/2<ruiseki[i-1]){
				s[j]=min(s[j],v[i]+ruiseki[i-1]-temp/2);
			}else if(temp/2>ruiseki[i]){
				s[j]=min(s[j],v[i]+temp/2-ruiseki[i]);
			}else{
				s[j]=min(s[j],v[i]);
			}
		}
	}

	ans=0;
	for(i=0;i<ruiseki[n]*2;i++){
		ans=ans+s[i]+s[i+1];
	}


	//	printf("計算部分終了\n");

	//出力
	printf("%lf",ans/4);

/*	for(i=0;i<=ruiseki[n]*2;i++){
		printf("i=%d,s[i]=%lf\n",i,s[i]);
	}*/

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 512
N = int(input())
X = list(map(int, input().split()))
Xmin = min(X)
Xmax = max(X)
HP = [0] * (Xmax - Xmin + 1)
P = Xmin
while P <= Xmax :
    for i in range(N) :
        HP[P-Xmin] += (X[i] - P) ** 2
    P += 1
print(min(HP))


Measured memory_bytes: 9112
N = int(input())
xy = []

for _ in range(N):
    tmp = input().split()
    xy.append([int(tmp[0]), int(tmp[1])])

# print(xy)
sum = 0
for i in range(N - 1):
    xyi = xy[i]
    # print(xy[i])

    for j in range(i + 1, N):
        xyj = xy[j]

        sum += ((xyi[0]-xyj[0])**2 + (xyi[1]-xyj[1])**2)**(1/2)
        # print("\t" + str(xy[j]))

print("{:.10f}".format(2*sum/N))


Measured memory_bytes: 3188
def main():
    X = int(input())

    X_div_100 = X // 100
    res_X_div_100 = X % 100

    count = 0

    while True:
        if res_X_div_100 >= 5:
            res_X_div_100 -= 5
            count += 1
        elif res_X_div_100 >= 4:
            res_X_div_100 -= 4
            count += 1
        elif res_X_div_100 >= 3:
            res_X_div_100 -= 3
            count += 1
        elif res_X_div_100 >= 2:
            res_X_div_100 -= 2
            count += 1
        elif res_X_div_100 >= 1:
            res_X_div_100 -= 1
            count += 1
        else:
            break

    if count <= X_div_100:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <utility>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int n;
    int x[50], y[50];
    cin >> n;
    for(int i=0;i<n;i++) cin >> x[i] >> y[i];

    map<pair<int,int>, int> mp;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            pair<int,int> p;
            p.first = x[i]-x[j];
            p.second = y[i]-y[j];
            auto itr = mp.find(p);
            if( itr != mp.end() ) {
                mp[p]++;
            } else {
                mp[p]=1;
            }
        }        
    }

    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        // cout << itr->first.first << ' ' << itr->first.second << ' ' << itr->second << endl;
        ans = max(ans, itr->second);
    }

    cout << n-ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int sum(const vi& a)
{
	return accumulate(allof(a),0);
}
int main()
{
	vvi a(2,vi(4));
	rep(i,2)
		rep(j,4)
			cin>>a[i][j];
	cout<<max(sum(a[0]),sum(a[1]))<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

#define snd second
#define fst first

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }

const int MAXN = 303;

int n;
int g[MAXN][MAXN];

int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    while (cin >> n) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                cin >> g[i][j];
            }
        }

        bool ok = true;
        ll answer = 0;
        for (int i = 0; i < n && ok; ++i) {
            for (int j = 0; j < n && ok; ++j) {
                bool f = false;
                for (int k = 0; k < n; ++k) {
                    if (k == i || k == j) {
                        continue;
                    }
                    if (g[i][k] + g[k][j] < g[i][j]) {
                        ok = false;
                        break;
                    }
                    f |= g[i][k] + g[k][j] == g[i][j];
                }
                if (!f) {
                    answer += g[i][j];
                }
            }
        }
        cout << (!ok? -1 : answer / 2) << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int n;
    cin >> n;
    vector<LL> ryuka(100);
    ryuka[0] = 2;
    ryuka[1] = 1;
    if(n <= 1){
        cout << ryuka[n] << endl;
        return  0;
    }
    for(int i = 2; i <= n; i++){
        ryuka[i] = ryuka[i-1] + ryuka[i-2];
    }
    cout << ryuka[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  ll res = 0;
  for(int i = 1;i <= n;i++){
    if(k >= i)continue;
    res += n;
    if(k > 0){
      ll base = n / i;
      res -= base * k;
      ll add = n % i;
      res -= min(add,k - 1);
    }
  }
  cout << res << endl;
  return 0;
}

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

namespace ConsoleApplication8
{
    //ONLINE JUDGE (ITP1_7_B)
    class Program
    {
        static void Main(string[] args)
        {
            
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int n = int.Parse(str[0]);
                int x = int.Parse(str[1]);

                if ((n == 0) && (x == 0))
                {
                    break;
                }

                int[] Array = new int[n];               //n?????§?????°???????????????????´?
                for (int i = 0; i < n; ++i)
                {
                    Array[i] = i + 1;
                }

                int count = 0;
                for (int i = 0; i < n - 2; ++i)
                {
                    for (int j = (i + 1); j < n - 1; ++j)
                    {
                        int sum = Array[i] + Array[j];
                        int a = x - sum;
                        if (Array[j] < a && a <= Array[n - 1])
                        {
                            ++count;
                        }

                        //if (sum >= x)
                        //{
                        //    break;
                        //}
                        //for (int k = (j + 1); k < n; ++k)
                        //{
                            
                        //    if ((sum + Array[k]) == x)
                        //    {
                        //        ++count;
                        //    }
                        //}
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5632
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


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


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


MOD = 10**9 + 7

n = ri()
ls = ril()
if n == 1:
    print(1)
    exit()

x = ls[0]
for i in range(1, n):
    x = lcm(x, ls[i])
ds = [x // y for y in ls]
print(sum(ds) % MOD)

Measured memory_bytes: 262644
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 605;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

int n, m, nn, e[N], cnt[N][N];
int g[N], dp[N][N], ans;

void init() {
	read(n); read(m);
	nn = 2 * (n - m);
	n <<= 1;
	for (int i = 1, u, v; i <= m; ++i) {
		read(u); read(v);
		e[u] = v;
		e[v] = u;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			cnt[i][j] = cnt[i][j - 1] + (!e[j]);
		}
	}
	g[0] = 1;
	for (int i = 2; i <= n; i += 2) {
		g[i] = Mul(g[i - 2], i - 1);
	}
}

void solve() {
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; ++j) {
			int flag = 1;
			for (int k = i; k <= j; ++k) {
				if (e[k] && (e[k] < i || e[k] > j)) {
					flag = 0; break;
				}
			}
			if (!flag) continue;
			dp[i][j] = g[cnt[i][j]];
			for (int k = i + 1; k < j; ++k) {
				Dec(dp[i][j], Mul(dp[i][k], g[cnt[k + 1][j]]));
			}
			Inc(ans, Mul(dp[i][j], g[nn - cnt[i][j]]));
		}
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


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

int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	
	if(l%d==0)
	  cout<<(r/d-l/d+1)<<endl;
	else
	  cout<<(r/d-l/d)<<endl;
	
	return 0;
}

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

int main() 
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 0; b < 9; b++) {
			int c;
			cin >> c;
			a -= c;
		}
		cout << a << endl;
	}
}

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

const int N = 1e6 + 10;
vector <int> sum ;
void add(vector<int >&T)
{
    vector<int> C;
    int t = 0;
    for(int i = 0;i<T.size()||i<sum.size();i++)
    {
        if(i<T.size()) t+=T[i];
        if(i<sum.size()) t+=sum[i];
        C.push_back(t%10);
        t/=10;
    }
    if(t)C.push_back(1);
    sum = C;
}
int main ()
{
    int n ;
    cin >> n ;
    for(int i = 1;i<= n; i++)
    {
        if(i % 5!=0 && i%3!=0)
        {
            int t = i;
            vector<int >T;
            while(t!=0)
            {
                int x= t%10;
                T.push_back(x);
                t/=10;
            }
            add(T);
        }
        
    }
    for(int i =sum.size()-1;i>=0;i--) cout<<sum[i];
    return 0 ;
}


Measured memory_bytes: 3636
n,a,b = gets.chomp.split(' ').map(&:to_i)
 
dist = b - a
 
if dist % 2 == 0 then
    puts dist /  2
else
    nDis = n - b
    oDis = a - 1
    if nDis < oDis then
        puts nDis+(dist-1)/2 + 1
    elsif oDis < nDis then
        puts oDis+(dist-1)/2 + 1
    else
        puts nDis+(dist-1)/2 + 1
    end
end

Measured memory_bytes: 3836
local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end
local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while (0 < pow) do
    if (pow % 2 == 1) then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end
local n = io.read("*n")
local invval = {}
for i = 1, n + 1 do
  invval[i] = modinv(i)
end
local facttop = {n - 1}
for i = 2, n - 1 do
  facttop[i] = bmul(facttop[i - 1], n - i)
end
local invfact = {1}
for i = 2, n + 1 do
  invfact[i] = bmul(invfact[i - 1], invval[i])
end

local function getComb(k)
  if 0 < k then return bmul(facttop[k], invfact[k])
  else return 1
  end
end

local a = {}
for i = 1, n + 1 do a[i] = io.read("*n") end
local t = {}
local midcnt = 0
for i = 1, n + 1 do
  if t[a[i]] then
    midcnt = i - t[a[i]] - 1
    break
  else
    t[a[i]] = i
  end
end

local midfacttop = {}
if 1 <= n - 1 - midcnt then
  midfacttop = {n - 1 - midcnt}
  for i = 2, n - 1 - midcnt do
    midfacttop[i] = bmul(midfacttop[i - 1], n - midcnt - i)
  end
end

local function getComb2(k)
  if 0 < k then return bmul(midfacttop[k], invfact[k])
  else return 1 end
end

if n == 1 then
  print("1\n1")
else
  for i = 1, n + 1 do
    local ret = 0
    -- case 0
    if i < n then
      ret = badd(ret, getComb(i))
    end
    -- case 1
    if i <= n then
      local all = getComb(i - 1)
      local without_mid = 0
      if i <= n - midcnt then
        without_mid = getComb2(i - 1)
      end
      local with_mid = bsub(all, without_mid)
      ret = badd(ret, without_mid)
      ret = badd(ret, (with_mid * 2) % mod)
    end
    -- case 2
    if 1 < i then
      ret = badd(ret, getComb(i - 2))
    end
    print(ret)
  end
end


Measured memory_bytes: 7476
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;
signed main(){
    string s,s1;
    cin >> s >> s1;
    int c = 0;
    for(int i =0;i<s.size();i++){
        if(s[i] != s1[i]) c++;
    }
    cout << c;
}


Measured memory_bytes: 3840
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (100006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
#warning "// FOR has been inclusive now!!!!"
ll n,R,G,B,co[MAXN],ans=1,two,full,first;
string A;
const ll MOD=998244353;
int main()
{
	FAST
	cin>>n>>A;
	FOR(i,0,3*n-1) { // R,G,B;
		if(A[i]=='R') {
			if(first==R);
			else if(R<two) ans*=(two-R); 
			else ans*=(first-R);
			++co[R++]; ans%=MOD;
		} if(A[i]=='G') {
			if(first==G);
			else if(G<two) ans*=(two-G); 
			else ans*=(first-G);
			++co[G++];ans%=MOD;
		} if(A[i]=='B') {
			if(first==B);
			else if(B<two) ans*=(two-B); 
			else ans*=(first-B);
			++co[B++];ans%=MOD;
		}
		while(two<n&&co[two]>=2) ++ two;
		while(full<n&&co[full]==3) ++ full;
		while(first<n&&co[first]>=1) ++ first;
	}
	// cerr<<'\n'<<ans<<'\n';
	FOR(i,1,n) ans*=i, ans%=MOD;
	cout<<ans<<'\n';
}
/*
3
RRRGGGBBB
*/ 
/*
2
BGRRGB
*/ 


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

int main() {
   int n,k,d,c;
   cin>>n>>k;
   bool ans[n+1]={0};
   for(int i=0;i<k;i++)
   {
   	cin>>d;
   	for(int j=0;j<d;j++)
   	{
     cin>>c;
     ans[c]=1;
   	}
   }
   int an=0;
   for(int i=1;i<=n;i++)
   	if(ans[i]==0)an++;
   cout<<an;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vec a(N);
    REP(i,N) cin>>a[i];
    int ans = 1;
    REP(i,N){
        if(a[i]==ans) ans++;
    }
    if(ans==1) cout<<"-1"<<endl;
    else cout<<N-ans+1<<endl;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

vector<vector<int>> dp(2000, vector<int>(2000));

void solve(string s, string t){
  int n = int(s.size());
  int m = int(t.size());

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
      }else{
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }

  cout << dp[n][m] << endl;
}

int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    string s, t;
    cin >> s >> t;
    solve(s, t);
  }
}



Measured memory_bytes: 18692
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
yes_flg = 1
for i in range(n-1):
    if a_ls[i] == a_ls[i+1]:
        yes_flg = 0
if yes_flg == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 25172
package main

import (
        "fmt"
)

func solution(n, k, q int, a []int) []string {
        p := make([]int, n)
        for i := 0; i < q; i++ {
                p[a[i]-1]++
        }

        out := make([]string, 0, n)
        for i := range p {
                if k-q+p[i] > 0 {
                        out = append(out, "Yes")
                } else {
                        out = append(out, "No")
                }
        }

        return out
}

func main() {
        var n, k, q int
        fmt.Scan(&n, &k, &q)
        a := make([]int, 0, q)
        for i := 0; i < q; i++ {
                t := 0
                fmt.Scan(&t)
                a = append(a, t)
        }
        for _, s := range solution(n, k, q, a) {
                fmt.Println(s)
        }
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e18;

int32_t main(){
	IOS;
	string S1,S2;
	cin>>S1>>S2;
	int s1=S1.length(),s2=S2.length();
	int dp[s1+1][s2+1];
	string ans;
	for(int i=0;i<=s1;i++){
		for(int j=0;j<=s2;j++){
			dp[i][j]=0;
		}
	}
	for(int i=1;i<=s1;i++){
		for(int j=1;j<=s2;j++){
			if(S1[i-1]==S2[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int c=dp[s1][s2];
	int i=s1,j=s2;
	while(c>0){
		if(dp[i-1][j]==dp[i][j]) i--;
		else if(dp[i][j-1]==dp[i][j]) j--;
		else{
			ans.pb(S1[i-1]);
			i--,j--;
			c--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll h,w,one=1;
    cin >> h >> w;//h>=Wとしてよい
    if(w>h){
        swap(h,w);
    }//hが長辺

    if((h*w)%3 == 0){
        cout << 0 << endl;
    }else{
        ll ans1=10000000002,ans2=10000000002,ans3=10000000002,ans4=10000000002;
        
        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((2*h/3)-1,one);j <= (2*h+3)/3;j++){
                ans1= min(ans1,max(w*i,max(w*(j-i),w*(h-j)))-min(w*i,min(w*(j-i),w*(h-j))));
            }
        }//長辺側から３分割する場合

        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((w/2)-1,one);j <= (2+w)/2 ;j++){
                ans2=min(ans2,max(w*i,max((h-i)*(w-j),(h-i)*j))-min(w*i,min((h-i)*(w-j),(h-i)*j)));
            }   
        }//まず長辺側で切り、次に短辺側で切る

        swap(h,w); 

        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((w/2)-1,one);j <= (w+2)/2;j++){
                ans3=min(ans3,max(w*i,max((h-i)*(w-j),(h-i)*j))-min(w*i,min((h-i)*(w-j),(h-i)*j)));
            }   
        }//まず短辺側で切り、次に長辺側で切る
        
        for(ll i=max((h/3)-1,one);i <= (h+3)/3;i++){
            for(ll j=max((2*h/3)-1,one);j <= (2*h+3)/3;j++){
                ans4= min(ans4,max(w*i,max(w*(j-i),w*(h-j)))-min(w*i,min(w*(j-i),w*(h-j))));
            }
        }//短辺側から３分割（場合分けの存在意義に疑問）

        cout << min(ans4,min(ans1,min(ans2,ans3))) << endl;
    }
}

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

int main() {
    int N,M;
    cin >> N >> M;
    if(N==M)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<bool> a(8,false);
  long long int haba = 0,ans = 0;
  for(int i=0;i<N;i++){
    long long int rate;
    cin >> rate;
    for(int j=0;j<8;j++){
      if(rate >= 400*j && rate < 400*(j+1)){
        a.at(j) = true;
        continue;
      }
    }
    if(rate >= 3200) haba++;
  }
  for(int i=0;i<8;i++){
    if(a[i]) ans++;
  }
  if(ans == 0){
    ans++;
    haba--;
  }
  cout << ans << " " << ans+haba << endl;
}
    

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

#define MAX 101010
#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

ll dp[MAX];
ll v[MAX];

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

  int n, k; cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> v[i];

  mset(dp, inf);
  dp[0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i; j <= i + k; ++j)
      if (j < n)
        dp[j] = min(dp[j], dp[i] + abs(v[j] - v[i]));

  cout << dp[n-1] << ende;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <limits.h>
 
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;


int count_honor(int syogen[15][15], int N, int bit)
{
    int honor_count = 0;
    for (int i = 0; i < N; i++)
    {
        if (bit & (1 << i))
        {
            for (int j = 0; j < N; j++)
            {
                //cout << (bit & (1 << j)) << endl;
                if (syogen[i][j] == -1)
                {
                }           
                else if((syogen[i][j] == 0) != ((bit & (1 << j)) == 0))
                {
                    return -1;
                }
            }
            ++honor_count;
        }
    }
    return honor_count;
}

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

    int syogen[15][15];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            syogen[i][j] = -1;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        for (int a = 0; a < A; a++)
        {
            int x, y;
            cin >> x >> y;
            syogen[i][x-1] = y;
        }
    }
    
    int max_honor = 0;
    for (int bit = 0; bit < (1<<N); ++bit)
    {
        max_honor = max(max_honor, count_honor(syogen, N, bit));
    }

    cout << max_honor << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
char str[200001];
char a[200001];
int main(void)
{
	int i,size=0;
	scanf("%s",str);
	a[size++]=str[0];
	for(i=1;str[i]!='\0';i++){
		if(str[i]=='S') a[size++]='S';
		else if(a[size-1]=='S') size--;
		else a[size++]='T';
	}
	printf("%d\n",size);
	return 0;
}    
    


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long a, m, n, sum;
multiset<long long> s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i=0;i<n;i++){
	cin >> a;
	s.insert(a);
}
for (int i=0;i<m;i++){
	multiset<long long>::iterator it=s.end(); it--;
	a=*it; s.erase(it); a>>=1; s.insert(a);
}
for (multiset<long long>::iterator it=s.begin(); it!=s.end();it++) sum+=*it;
cout << sum;
return 0;
}

Measured memory_bytes: 4992
import java.io.*;
 
/**
 * Created by Ayushi on 22 Aug 2020.
 * Problem:
 * Round:
 */
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String a  = br.readLine();
        long ans = 0;
        for (int i = 0; i < a.length(); i++) {
          ans += Integer.parseInt(a.substring(i,i+1));
        }

        System.out.println((ans%9==0) ? "Yes":"No");
        //System.out.println(ans);
    }
}

Measured memory_bytes: 45480
//おまじない
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
 
int main() {
int a,b;
  cin>>a>>b;
  if((1<=a&&a<=9)&&(1<=b&&b<=9)){
    cout<<a*b<<endl;
  }
  
  else{
    cout<<"-1"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int K = in.nextInt();
		int ans = 1;
		N -= K;
		if(N >= 1) ans += (int)Math.ceil(1.0 * N / (K - 1));
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
// c++ -std=c++14 atcoder.cpp
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

int main(){

int N,M;
int A[N];
int result=0;
cin>>N>>M;
rep(i,N)cin>>A[i];
rep(i,N)result+=A[i];
sort(A,A+N,greater<int>());
if(A[M-1]>=(float)result/(4*M))cout<<"Yes"<<endl;
else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

int n;

int main()
{
    ///freopen("INA.txt","r",stdin);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>> n;
    cout<< (n*(n+1))/2 << endl;


    return 0;
}



Measured memory_bytes: 3576
n, x = map(int, input().split())

a = [1]
p = [1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x <= 1+a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])

print(f(n,x))

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

int main()
{
  int N;
  int L[2200]={0};
  cin>>N;
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  sort(L,L+N);
  for(int i=N-1;i>=2;i--){
    for(int j=i-1;j>=1;j--){
      for(int k=j-1;k>=0;k--){
        if(L[i]<L[j]+L[k])ans+=1;
        else break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		 
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int i=0;
		int p;
		while(true) {
			if(c==0) {
				break;
			}else {
				p=b-a;
				if(p<0) break;
				i++;
				while(p>=a && c>i) {
					p=p-a;
					i++;
				}
				break;
			}
		}
	System.out.println(i);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  ll ans=0;
  REP(i,n){
    if(i==0) continue;
    ll temp=a[i-1]+a[i];
    if(temp>x){
      a[i]=max(ll(0),a[i]-temp+x);
      ans+=temp-x;
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>
const int N=1e3+10;

const int M = ((int)1e9 + 7);

int n,m;





signed main(){
   fast;
   cin>>n;
   cout<<n*n;
  
   //solve();//length,
  	
   
   
}

Measured memory_bytes: 256
# mを法とするときのa^n
def modpow(a,n,m):
    res = 1
    t = a
    while n:
        if n%2:
            res = (res*t)%m
        t = (t*t)%m
        n //= 2
    return res

MOD = 998244353

N = int(input())
D = list(map(int,input().split()))

if D[0] != 0 or any(d == 0 for d in D[1:]):
    print(0)
    exit()

memo = [0]*(max(D)+1)
for d in D:
    memo[d] += 1



cnt = 1
for a,b in zip(memo, memo[1:]):
    cnt *= modpow(a,b,MOD)
    cnt %= MOD

print(cnt)



Measured memory_bytes: 55212