akhauriyash/Code-Regression huggingface dataset:
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    string s;
    cin >> s;
    bool flag = true;
    while(flag) {
        if(s.size()==0) {
            print("YES");
            return 0;
        }
        int ssize = s.size();
        if(s.substr(max(ssize-7, 0), min(7,ssize))=="dreamer") {
            s.erase(s.begin()+s.size()-7, s.end());
            continue;
        }
        if(s.substr(max(ssize-5, 0), min(5,ssize))=="dream") {
            s.erase(s.begin()+s.size()-5, s.end());
            continue;
        }        
        if(s.substr(max(ssize-6, 0), min(6,ssize))=="eraser") {
            s.erase(s.begin()+s.size()-6, s.end());
            continue;
        }
        if(s.substr(max(ssize-5, 0), min(5,ssize))=="erase") {
            s.erase(s.begin()+s.size()-5, s.end());
            continue;
        }
        break;
    }

    print("NO");

    return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    A, B = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))
    print(A * B)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 100"""
        output = """10000"""
        self.assertIO(input, output)



Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin>>N;
    vector<int> x(N);
    vector<vector<int>> tree(N);
    REP(i,N-1) {
        int p;
        cin>>p;
        tree[p-1].push_back(i+1);
    }
    cin>>x;

    function<int(int)> dfs=[&](int v) {
        int ret=0;
        vector<vector<bool>> dp(SZ(tree[v])+1,vector<bool>(5001,false));
        int idx=0;
        dp[0][0]=true;
        FORE(w,tree[v]) {
            int s=dfs(w);
            REP(j,5001) {
                if(dp[idx][j]) {
                    if(j+(s-x[w])<=5000) dp[idx+1][j+(s-x[w])]=true;
                    if(j+x[w]<=5000) dp[idx+1][j+x[w]]=true;
                }
            }
            ret+=s;
            idx++;
        }
        bool possible=false;
        int weight=0;
        REPR(i,x[v]) {
            if(dp[idx][i]) {
                possible=true;
                weight=x[v]-i;
                break;
            }
        }
        if(!possible) {
            cout<<"IMPOSSIBLE"<<endl;
            exit(0);
        }
        return ret+weight;
    };
    dfs(0);
    cout<<"POSSIBLE"<<endl;
    return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int n;cin>>n;
	for(int i=1;i<=10;i++)
	{
		if(n<1000&&n>0)
		{
			cout<<1000-n;
			return 0;
		}
		n-=1000;
	}
	cout<<0;
}


Measured memory_bytes: 3640
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;

void san(int n, string s ,int sum)
{
	for (int i = 2;i < n;i++) {
		if (s[i - 2] == 'A' and s[i - 1] == 'B' and s[i] == 'C')
			sum++;
	}cout << sum;
}
int main()
{/*五日目*/	
//関数使ってみるよ(五日目)
	int n;cin >> n;
	string s;cin >> s;
	san(n, s, 0);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000009;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int N, P[9], Q[9];
int a, b;

int cnt = 0, tmp[9];
bool vst[9];

void rec(int n, int d) {
    tmp[d] = n;
    vst[n] = true;
    if (d < N - 1) {
        REP (i, N) {
            if (!vst[i + 1]) {
                rec(i + 1, d + 1);
            }
        }
    }
    else {
        cnt++;
        bool f = true, g = true;
        REP(i, N) {
            f &= (P[i] == tmp[i]);
            g &= (Q[i] == tmp[i]);
        }
        if (f) {
            a = cnt;
        }
        if (g) {
            b = cnt;
        }
    }
    vst[n] = false;
}

void dfs() {
    REP (i, N) {
        vst[i] = 0;
    }
    REP (i, N) {
        rec(i + 1, 0);
    }
}

int main() {
    cin >> N;
    REP (i, N) {
        cin >> P[i];
    }
    REP (i, N) {
        cin >> Q[i];
    }
    dfs();
    cout << abs(a - b) << endl;
    return 0;
}


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

const int MAX_N = 200005, MAX_K = 11, MOD = 998244353;
int N;
int K;
int rnst[MAX_K], rnen[MAX_K];
int dp[MAX_N];
int cum[MAX_N];

int cums(int st, int en) {
  if (en < 0) return 0;
  st = std::max(0, st);
  if (st == 0) return cum[en];
  return (cum[en] - cum[st - 1] + MOD) % MOD;
}

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < K; ++i)
    scanf("%d %d", rnst + i, rnen + i);
  dp[0] = 1;
  cum[0] = 1;
  for (int i = 1; i <= N; ++i) {
    int v = 0;
    for (int k = 0; k < K; ++k) {
      v += cums(i - rnen[k], i - rnst[k]);
      v = v % MOD;
    }
    dp[i] = v;
    cum[i] = (cum[i - 1] + v) % MOD;
  }
  printf("%d\n", dp[N-1]);
}


Measured memory_bytes: 5376
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<string> s(n);
        for(int i=0; i<n; ++i)
            cin >> s[i];

        vector<vector<int> > dp(n, vector<int>(n, 0));
        int ret = 0;
        for(int i=0; i<n; ++i){
            if(s[0][i] == '.'){
                dp[0][i] = 1;
                ret = 1;
            }
            if(s[i][0] == '.'){
                dp[i][0] = 1;
                ret = 1;
            }
        }
        for(int i=1; i<n; ++i){
            for(int j=1; j<n; ++j){
                if(s[i][j] == '.'){
                    dp[i][j] = min(dp[i-1][j-1], min(dp[i][j-1], dp[i-1][j])) + 1;
                    ret = max(ret, dp[i][j]);
                }
            }
        }
        cout << ret << endl;
    }
}

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

using namespace std;

int main() {
  // N: anything with a lineup like this makes me worry about
  // the fancy DP techniques... I don't want to have to do
  // divide-and-conquer DP :'(
  // but luckily it looks like it's just a range DP, which
  // is much better!
  // because O(n^3) fits in time

  cin.tie(0);
  cin.sync_with_stdio(0);
  int n; cin >> n;
  long long a[n];
  long long apref[n+1];
  apref[0] = 0;
  for(int i = 0; i<n; ++i) {
    cin >> a[i];
    apref[i+1] = apref[i] + a[i];
  }

  // dp[i][j] = the min. cost to merge everything in the range
  // i - j
  long long dp[n][n];
  for(int i = 0; i<n; ++i) {
    for(int j = 0; j<n; ++j) {
      dp[i][j] = LLONG_MAX;
    }
  }

  for(int len = 0; len<n; ++len) {
    for(int i = 0; i+len<n; ++i) {
      if(len == 0) {
        dp[i][i+len] = a[i];
      }
      else {
        for(int j = i; j<i+len; ++j) {
          // split to the right of j
          // ugh great, more prefix sums
          dp[i][i+len] = min(dp[i][i+len], apref[i+len+1]-apref[i] + dp[i][j] + dp[j+1][i+len]);
        }
      }
    }
  }
  // idk why it's off by this amount exactly??
  cout << dp[0][n-1]-apref[n] << endl;
}


Measured memory_bytes: 1536
import kotlin.math.min

fun main() {
    val s = readLine() ?: return
    val k = readLine()?.toInt() ?: return

    val list = mutableSetOf<String>()
    val find = StringBuilder()
    'a'.until('z' + 1).forEach { c ->
        0.until(s.length).forEach { i ->
            val si = s[i]
            if (si == c) {
                find.clear()
                find.append(si.toString())
                list.add(find.toString())
                (i + 1).until(min(i + k, s.length)).forEach { j ->
                    find.append(s[j])
                    list.add(find.toString())
                }
            }
        }
        if (list.size >= k + 1) {
            println(list.sorted()[k - 1])
            return
        }
    }
    println(list.sorted()[k - 1])
}


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

int N,P[3000][2],i,d[3000][3000];
char f[5001][5001];


int main()
{
	int a,b,r;
	for(;scanf("%d",&N),N;)
	{
		r=0;
		memset(f,0,sizeof(f));
		for(i=0;i<N;i++)
		{
			scanf("%d%d",&P[i][0],&P[i][1]);
			f[P[i][0]][P[i][1]]=1;
		}
		for(a=0;a<N;a++)
			for(b=0;b<N;b++)
			{
				int ax=P[a][0],ay=P[a][1],bx=P[b][0],by=P[b][1],dx=bx-ax,dy=by-ay;
				if(dx>=0&&dy>=0&&bx+dy<=5000&&ay-dx>=0&&f[ax+dy][ay-dx]&&f[bx+dy][by-dx])
					r=r<dx*dx+dy*dy?dx*dx+dy*dy:r;
			}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 25424
package main

import (
	"fmt"
	"strings"
)

func main() {

	// erasedream yes
	// dreameraser yes
	// eraserdreameraser
	// dreamerer no
	// dream dreamer erase eraser
	var s string
	fmt.Scan(&s)

	s = strings.Replace(s, "eraser", "", -1)
	s = strings.Replace(s, "erase", "", -1)
	s = strings.Replace(s, "dreamer", "", -1)
	s = strings.Replace(s, "dream", "", -1)

	if len(s) == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1664
from collections import deque

s = deque(list(input()))
n = int(input())
f = True

for i in range(n):
    a = input()
    if a == "1":
        f = not f
    else:
        b,c,d = a.split()
        if f:
            if c == "1":
                s.appendleft(d)
            else:
                s.append(d)
        else:
            if c == "1":
                s.append(d)
            else:
                s.appendleft(d)

if not f:
    s.reverse()

ans = "".join(s)
print(ans)



Measured memory_bytes: 8420
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            int k = nint(sc);
            int s = nint(sc);
            int count = 0;
            for (int i = 0; i <= k; i++) {
                for (int j = 0; j <= k; j++) {
                    if(s-i-j<=k && 0 <= s-i-j){
                        count ++;
                    }
                }
            }
            out.println(count);

        }

    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

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


Measured memory_bytes: 22868
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
    int d;
    string a,b,c;
    double q;
   while(cin>>a>>b){
        c=a+b;
   d=0;
    for(int i=0;i<c.length();i++)
        {d=d*10+c[i]-'0';
        //cout<<d<<endl;
        }
    q=sqrt(d);
    if(q==ceil(q))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
   }
}

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

void DBG(){
    cerr << "]\n";
}
template <class H, class... T> void DBG(H h, T... t) {
    cerr << h;
    if (sizeof...(t)) {
        cerr << ", ";
    }
    DBG(t...);
}
#define _DEBUG
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else 
#define dbg(...) 0
#endif

ll n,ans;

int main() {
    cin >> n;
    ans = n;
    for (int i = 1; i < n; i++) {
        ans += (i + 1) * (n - i);
        ll a, b;
        cin >> a >> b;
        if (a > b)
            swap(a, b);
        ans -= a * (n - b + 1);
    }
    cout << ans << endl;
}

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

struct syogen{
    int x;
    int y;
};

int main() {
    int N; cin >> N;
    vector<vector<syogen> > A(N, vector<syogen>(N));
    rep(i, N){
        int a; cin >> a;
        rep(j, a){
            cin >> A[i][j].x >> A[i][j].y;
        }
    }

    queue<int> X;
    bool check = true;
    rep(i, 1<<N){
        check = true;
        rep(j, N){
            if(i>>j&1){
                rep(k, A[j].size()){
                    if(A[j][k].y == (i>>(A[j][k].x-1)&1)){
                        continue;
                    } else {
                        check = false;
                        break;
                    }
                }
            }
            if(!check)break;
        }
        if(check)X.push(i);
    }

    int ans = 0;
    while(!X.empty()){
        int temp = 0;
        int g = X.front(); X.pop();
        rep(i, N){
            temp += g%2;
            g /= 2;
        }
        ans = max(ans,temp);
    }

    cout << ans << endl;
}

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

int main() {
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll arr[n+1][m+1];
    for(int i=0;i<=m;i++)
    arr[0][i]=0;
    for(int i=0;i<=n;i++)
    arr[i][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {   
            if(s[i-1]==t[j-1])
            arr[i][j]=1+arr[i-1][j-1];
            else
            arr[i][j]=max(arr[i-1][j],arr[i][j-1]);

        }
 
    }
   string ans;
   int i=n,j=m,len=arr[n][m];
   while(len>0)
   {
       if(arr[i-1][j]==len)
       i--;
       else if(arr[i][j-1]==len)
       j--;
       else
       {
           ans=ans+s[i-1];
           i--;
           j--;
           len--;
       }
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;
  
    
}

Measured memory_bytes: 70656
#include<iostream>
#include<vector>
#include<queue>

using namespace std;


int main(){
	char a1[5] = {'.',',','!','?',' '}; 
	char a2[3] = {'a','b','c'};
	char a3[3] = {'d','e','f'};
	char a4[3] = {'g','h','i'};
	char a5[3] = {'j','k','l'};
	char a6[3] = {'m','n','o'};
	char a7[4] = {'p','q','r','s'};
	char a8[3] = {'t','u','v'};
	char a9[4] = {'w','x','y','z'};
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		string str;
		cin >> str;
		if (cin.eof()) break;
		char num;
		int cnt = 0;	
		for (int i = 0; i < str.size(); i++){	
			cnt++;
			if (str[i] == '0'){
				if (str[i-1] == '1'){ 
					cout << a1[(cnt - 2)%(sizeof(a1))]  ;
				}else if (str[i-1] == '2'){
					cout << a2[(cnt - 2)%(sizeof(a2))]  ;
				}else if (str[i-1] == '3'){
					cout << a3[(cnt - 2)%(sizeof(a3))]  ;
				}else if (str[i-1] == '4'){
					cout << a4[(cnt - 2)%(sizeof(a4))]  ;
				}else if (str[i-1] == '5'){
					cout << a5[(cnt - 2)%(sizeof(a5))]  ;
				}else if (str[i-1] == '6'){
					cout << a6[(cnt - 2)%(sizeof(a6))]  ;
				}else if (str[i-1] == '7'){
					cout << a7[(cnt - 2)%(sizeof(a7))]  ;
				}else if (str[i-1] == '8'){
					cout << a8[(cnt - 2)%(sizeof(a8))]  ;
				}else if (str[i-1] == '9'){
					cout << a9[(cnt - 2)%(sizeof(a9))]  ;
				}
				cnt = 0;
			}
		}
		cout << endl;
	}
	
return 0;
}

Measured memory_bytes: 3048
'use strict';
(function (stdin) {
    const [n, ...R] = stdin.toString().trim().split('\n').map(Number);
    let minv = R[0], maxv = R[1] - R[0];
    for (let idx = 1; idx < n; idx++) {
        maxv = (maxv > R[idx] - minv) ? maxv : R[idx] - minv;
        minv = (minv < R[idx]) ? minv : R[idx];
    }
    console.log(maxv);
})(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 48656
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(m)]
A.sort(key=lambda x: x[1])

posi = 0
count = 0
for a in A:
    if a[0] > posi:
        posi = a[1] - 1
        count += 1
        
print(count)

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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;
            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (n == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

}

Measured memory_bytes: 384
S = input()
N = len(S)
even=(N%2==0) 
a=N//2 + (not even) 
b=a

for i in range(N//2-even, N-1):
  if S[i]!=S[i+1]:
    break 
  else:
    b+=1
for i in range(N//2,0,-1): 
  if S[i]!=S[i-1]:
    break 
  else:
    a+=1
ans=min(a,b ) 

print(ans)

Measured memory_bytes: 39536
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for l in range(N + 1):
    for r in range(N + 1):
        if l + r > N:
            continue
        k = K - (l + r)
        if k < 0:
            continue

        A = V[:l] + V[N - r:]
        A.sort(reverse=True)
        while k > 0 and A and A[-1] < 0:
            A.pop()
            k -= 1
        ans = max(ans, sum(A))
print(ans)


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); --i)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF * INF;

const int MAX = 100100;

int A[MAX];
int n;

LL get(int sign)
{
	LL res = 0;
	LL s = 0;
	FOR (i, 0, n)
	{
		s += A[i];
		if (sign == 1)
		{
			if (s < 1)
			{
				res += 1 - s;
				s = 1;
			}
		}

		if (sign == -1)
		{
			if (s > -1)
			{
				res += s + 1;
				s = -1;
			}
		}

		sign *= -1;
	}
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	scanf("%d", &n);

	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
	}

	LL res = min(get(1), get(-1));

	cout<<res<<endl;
}


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

int main(void){
    int n, k, t, a = 0;
    cin >> n >> k;
    vector<int> p(n);
    
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    for(int j = 0; j < k; j++){
        a += p[j];
    }
    cout << a << endl;
}

Measured memory_bytes: 3600
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  vector<int> A(6);
  loop(i,0,6) in(A[i]);
  
  ll max_w = A[0], max_s = 0;
  loop(a,0,31) loop(b,0,31) loop(c,0,101) {
    int w = a*A[0] + b*A[1];
    int s_cap = w*A[4]-c*A[2];
    if (s_cap<0) continue;
    int w_cap = A[5]-100*w-c*A[2];
    if (w_cap<0) continue;
    int d = min(s_cap/A[3], w_cap/A[3]);
    int s = c*A[2] + d*A[3];
    if (w==0 or s == 0) continue;
    if (max_w+max_s==0) {
      max_w = w; max_s = s; continue;
    }
    if ((w+s)*max_s < (max_w+max_s)*s) {
      max_w = w; max_s = s;
    }
  }
  print(100*max_w+max_s, " ");
  print(max_s);
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
long bigp = 1000000007;


int main(){
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << double(w*h)/2 << " ";
  if(2*x==w && 2*y==h){
    cout << "1";
  }
  else{cout << "0";}
}

Measured memory_bytes: 256
import math

cnt = 0

def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            cnt += 1
            j -= g
        A[j+g] = v

def shellSort(A, n):
    g = int(n/2) + 1
    G = []
        
    while g > 0:
        G.append(g)
        insertionSort(A, n, g)
        g = int(g/2)
    
    return G

n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
G = shellSort(A,n)

print(len(G))
print(" ".join(map(str, G)))
print(cnt)
for i in A:
    print(i)


Measured memory_bytes: 45576
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
int a[111];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)
	{
		geti(a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;)
	{
		int r=i;
		while(a[i]==a[r]&&r<=n)r++;
		ans+=(r-i)/2;
		i=r;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll ss=s.size(),ans=0,ans1=0;
  for(ll i=0;i<ss;i++){
    if(i%2==0){
      if(s[i]=='1') ans++;
    }
    else {
      if(s[i]=='0') ans++;
    }
  }
  for(ll i=0;i<ss;i++){
    if(i%2==0){
      if(s[i]=='0') ans1++;
    }
    else {
      if(s[i]=='1') ans1++;
    }
  }
  cout <<min(ans,ans1)<<endl;
}


Measured memory_bytes: 512
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define PRINT
#define LCERR
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:
    vector<int> preparing_boxes(const vector<int>& a) {
        const int N = a.size() - 1; // a[0] is not used
        vector<int> boxes(N + 1);
        for (int i = N; i > 0; --i) {
            int sum_multipliers = 0;
            for (int j = i * 2; j <= N; j += i) {
                sum_multipliers += boxes[j];
            }
            sum_multipliers %= 2;
            if (a[i] != sum_multipliers)
                boxes[i] = 1;
            else
                boxes[i] = 0;
        }
        vector<int> result;
        for (int i = 1; i <= N; ++i) {
            if (boxes[i] == 1)
                result.emplace_back(i);
        }
        return result;
    }
private:

};

int solve() {
    Solution solution;
    // handle IO here
    int N;
    cin >> N;
    vector<int> a(N + 1);
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
    }
    auto boxes_with_balls = solution.preparing_boxes(a);
    cout << boxes_with_balls.size() << endl;
    for (size_t i = 0; i + 1 < boxes_with_balls.size(); ++i) {
        cout << boxes_with_balls[i] << ' ';
    }
    if (!boxes_with_balls.empty())
        cout << boxes_with_balls.back() << endl;
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long DP[100001],N,K;
	pair<long long,long long>item[101];
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		cin>>item[i].first>>item[i].second;
	}
	for(int i=0;i<100001;i++)
	{
		DP[i]=INT_MAX;
	}
	DP[0]=0;
	for(int i=0;i<101;i++)
	{
		for(int j=100000;j>=0;j--)
		{
			if(DP[j]!=INT_MAX)
			{
				DP[j+item[i].second]=min(DP[j+item[i].second],DP[j]+item[i].first);
			}
		}
	}
	for(int i=100000;i>=0;i--)
	{
		if(DP[i]<=K)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n,m;cin >> n >> m;
  vector<int> s(n), t(m);
  rep(i,n) cin >> s[i];
  rep(i,m) cin >> t[i];

  vector<vector<mint>> dp(n, vector<mint>(m));
  vector<vector<mint>> sum(n+1, vector<mint>(m+1));
  rep(i,n) {
    rep(j,m) {
      if(s[i] == t[j]) {
	dp[i][j] = sum[i][j] + (mint)1;
      }
      sum[i+1][j+1] = dp[i][j] + sum[i][j+1] + sum[i+1][j] - sum[i][j];
    }
  }

  mint res(1);
  rep(i,n) {
    rep(j,m) {
      res += dp[i][j];
    }
  }

  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 62976
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);
string st, ts;
int sx, sy, tx, ty;

int main(void) {
	cin >> sx >> sy >> tx >> ty;
	for (int i = 0; i < ty - sy; i++) {
		st += 'U';
		ts += 'D';
	}
	for (int i = 0; i < tx - sx; i++) {
		st += 'R';
		ts += 'L';
	}

	cout << st << ts;
	cout << "LU" + st + "RD";
	cout << "RD" + ts + "LU";

}

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

int main() {
  ll N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  vi v(N);
  ll ans = 0;
  rep(i, 0, N) {
    ll x;
    if (T[i] == 'r') x = 'p';
    else if (T[i] == 's') x = 'r';
    else x = 's';
    if (i >= K) {
      if (v[i - K] == x) x = 'x';
    }
    v[i] = x;
    if (x == 'p') ans += P;
    else if (x == 's') ans += S;
    else if (x == 'r') ans += R;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
#include<queue>
#include<map>
#include<string.h>
#include<algorithm>
using namespace std;

/*
最短路拆点，跑最短路；
*/

const int N=1e6+10;
const int INF=0x3f3f3f3f;

map<pair<int,int>,int>mp;

struct asd{
    int to;
    int w;
    int next;
};
int head[N*8],tol,dd;
asd q[N*8];
int num[N*8];
bool vis[N*8];
int dis[N*8];
int n,m;
int que[N];
int s,t;

int spfa()
{
    s=0;
    t=1;
    for(int i=1;i<=dd+1;i++)
    {
        dis[i]=INF;
        vis[i]=0;
        num[i]=0;
    }
    dis[1]=0;
    vis[1]=num[1]=1;
    que[s]=1;
    while(s<t)
    {
        int u=que[s];
        s++;
        vis[u]=0;
        for(int v=head[u];v!=-1;v=q[v].next)
        {
            int i=q[v].to;
            if(dis[i]>q[v].w+dis[u])
            {
                dis[i]=q[v].w+dis[u];
                if(!vis[i])
                {
                    num[i]++;
                    if(num[i]>=dd)
                        return -2;
                    vis[i]=1;
                    que[t]=i;
                    t++;
                }
            }
        }
    }
    if(dis[n]!=INF)
        return dis[n];
    else
        return -2;
}
int getid(int x,int y)
{
    if(mp.find({x,y})!=mp.end())
        return mp[{x,y}];
    return mp[{x,y}]=++dd;
}
void init()
{
    dd=n;
    tol=0;
    memset(head,-1,sizeof(head));
}
void add(int a,int b,int c)
{
    q[tol].w=c;
    q[tol].to=b;
    q[tol].next=head[a];
    head[a]=tol++;
}
int main()
{
    scanf("%d%d",&n,&m);
    init();
    for(int i=0;i<m;i++)
    {
        int x,y,c;
        scanf("%d%d%d",&x,&y,&c);
        int xx=getid(x,c);
        int yy=getid(y,c);
        add(xx,yy,0);
        add(yy,xx,0);
        add(x,xx,1);
        add(xx,x,1);
        add(y,yy,1);
        add(yy,y,1);
    }
    printf("%d\n",spfa()/2);
    return 0;
}

Measured memory_bytes: 85120
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
#define sq(x) (x*x*x*x*x)
#define fr(i,m,n) for(i=m;i<n;i++)
#define vec vector<int>
#define sint set<int>
#define qint queue<int>
#define mip map<int,int>
#define pint priority_queue<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define full(v) v.begin(),v.end()
int main()
{
    lld i,j,k,a,b,c,x,y,z,n,m,t;
    string s,u,v;
    cin>>c;bool ans=false;
    fr(i,0,1000){
        x=sq(i);z=x-c;
        fr(j,0,1000){
            y=sq(j);
                if(y==abs(z)){ans=true;break;}
                else if(y>abs(z)) break;
        }
        if(ans) break;
    }
    if(z>=0) cout<<i<<" "<<j<<endl;
    else cout<<i<<" "<<-j<<endl;
}



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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}



int main()
{
	FASTIO;
	ll n;
	 cin>>n;
	 vector<ll>vect(n);
	 f(i,0,n)
        cin>>vect[i];

        sort(vect.begin(),vect.end());
        ll middle= n/2-1;

        cout<<vect[middle+1]-vect[middle];

	return 0;
}













Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<limits.h>
#include <iomanip> 
using namespace std;


int N;
double x[10], y[10];
double distances[10][10];
double totaldistance = 0;
int main(){
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            distances[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
            totaldistance += distances[i][j];
        }
    }
    cout << std::fixed << std::setprecision(15) << totaldistance / N << endl;
    return 0;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double tA = (H * 60 + M) * ((double)M_PI / 360);
    double tB = M * ((double)M_PI / 30);
    double th = abs(tA - tB);
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(th));
    printf("%.16f\n", ans);
}

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

/*
#include <chrono>
int main()
{
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();

    resolve();

    end = chrono::system_clock::now();
    double time = static_cast<double>(
        chrono::duration_cast<chrono::microseconds>(end - start).count() /
        1000.0);
    cout << "resolve(): " << time << "[ms]" << endl;

    return 0;
}
*/


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

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

    if(abs(a - c) <= d){
        cout << "Yes" << endl;
        return 0;
    }

    if(abs(a - b) <= d && abs(b - c) <= d){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int H1 = Integer.parseInt(sc.get());
		int M1 = Integer.parseInt(sc.get());
		int H2 = Integer.parseInt(sc.get());
		int M2 = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		var hour = H2 - H1;
		var minutes = M2 - M1;
		System.out.println(hour * 60 + minutes - K);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,r,s=0,i,j;
    string ch;
    cin>>ch;
    for(i=0;i<ch.length();i++){
        s+=ch[i]-'0';
    }
    cout<<(s%9==0?"Yes\n":"No\n");
}


Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int c[3][3];
    bool ok=true;
    for (int i=0; i<3; i++) for (int j=0; j<3; j++) cin>>c[i][j];
    //if (c[0][1]==c[1][0]) && (c[0][2]==c[2][0]) && c[1][2]==c[2][1]) ok=true;
    int b=c[0][0]-c[0][1];
    if (!(b==c[1][0]-c[1][1] && b==c[2][0]-c[2][1])) ok=false;
    b=c[0][1]-c[0][2];
    if (!(b==c[1][1]-c[1][2] && b==c[2][1]-c[2][2])) ok=false;
    if (ok) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      //n 枚数 r 操作回数
      int n = Integer.parseInt(sc.next());
      int r = Integer.parseInt(sc.next());
      int[] cards = new int[n];
      //cards[0]が一番下
      for(int i = 0; i < n; i++) cards[i] = i + 1;
      if(n == 0 && r == 0) break;
      for(int i = 0; i < r; i++){
        cards = swap(cards, Integer.parseInt(sc.next()), Integer.parseInt(sc.next()), n);
      }
      //for(int v: cards) System.out.printf("%d\n", v);
      System.out.printf("%d\n", cards[n - 1]);
    }
  }

  public static int[] swap(int[] cards, int a, int b, int n){
    int[] cards_1 = new int[n];
    int[] cards_2 = new int[n];
    int[] cards_3 = new int[n];
    cards_1 = Arrays.copyOfRange(cards, n - a + 1, n);
    cards_2 = Arrays.copyOfRange(cards, n - a - b + 1, n - a + 1);
    cards_3 = Arrays.copyOfRange(cards, 0, n - a - b + 1);
    IntStream stream1 = Arrays.stream(cards_1);
    IntStream stream2 = Arrays.stream(cards_2);
    IntStream stream3 = Arrays.stream(cards_3);


    IntStream stream32 = IntStream.concat(stream3, stream1);
    stream32 = IntStream.concat(stream32, stream2);
    return stream32.toArray();
  }
}


Measured memory_bytes: 42012
def p_prime(n): 
    prime = [2]
    for i in range(3,n+1):
        flag = 0
        for j in prime:
            if i%j == 0:
                flag = 1
                break
            if i**0.5 < j:
                break
        if flag == 0:
            prime.append(i)
    return prime

import time

A,B = list(map(int,input().split()))
import fractions

M = fractions.gcd(A,B)

a = {}
prime = p_prime(int(M**0.5+1))
for p in prime:
    count = 0
    while M%p ==0:
        count += 1
        M //= p
    if count > 0:
        a[p] = count
if M != 1:
    a[M] = 1

print(len(a)+1)

Measured memory_bytes: 69848
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  for (i64 _ = 0; _ < N; _++)
  {
    string a, b;
    cin >> a >> b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    string ans;
    bool up = false;
    for (i64 i = 0; i < max(a.size(), b.size()); i++)
    {
      i64 n = (i < a.size() ? a[i] - '0' : 0) + (i < b.size() ? b[i] - '0' : 0) + (up);
      up = 10 <= n;
      ans += (char)((n % 10) + '0');
    }
    if (up)
      ans += "1";
    reverse(ans.begin(), ans.end());
    if (80 < ans.size())
      cout << "overflow" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}



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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    vll A(N); REP(i, N) cin >> A[i];
    vll B(N); REP(i, N) B[i] = A[i] - i - 1;

    sort(B.begin(), B.end());

    ll l = B[0], h = B[N-1];
    REP(k, 100) {
        ll a = (2 * l + h) / 3;
        ll b = (l + 2 * h) / 3;

        ll aa = 0; REP(i, N) aa += llabs(B[i] - a);
        ll bb = 0; REP(i, N) bb += llabs(B[i] - b);

        if (aa > bb) l = a;
        else h = b;
    }

    ll ans = 1LL << 50;
    FOR(i, l, h + 1) {
        ll ans1 = 0; REP(j, N) ans1 += llabs(B[j] - i);
        ans = min(ans, ans1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,a[100001],axor=0;
	map<ll,bool> sax;
	scan(N);
	rep(i,N){
		scan(a[i]);
		axor^=a[i];
		sax[a[i]^(a[i]-1)]=1;
	}
	int nowbit=0;
	int ans=0;
	brep(i,35){
		if(((axor>>i)&1)!=nowbit){
			nowbit^=1;
			if(sax[(1LL<<(i+1))-1]==0){
				prin(-1);
				return 0;
			}
			ans++;
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1024