akhauriyash/Code-Regression huggingface dataset:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# inputを高速化する。
input = sys.stdin.readline
# 入力
vacation = int(input())
lst_happiness = [list(map(int, input().split())) for i in range(vacation)]
# DPテーブル
# 最大化問題なので0で初期化
dp = [[0 for i in range(3)] for j in range(vacation+1)]
# dpの最大値を更新するための関数
def chmax(a, b):
    if a > b:
        return a
    else:
        return b
# メモ化再帰の関数
def rec(i):
    # DPの値が既に更新されている場合はその値を返す
    for j in range(3):
        if dp[i][j] > 0:
            break
        
        # 再帰の終了条件
        if i == 0:
            dp[i][j] = 0
            break
        
        # i-1 を再帰
        res = 0
        for k in range(3):
            if j == k:
                continue
            res = chmax(res, rec(i-1)[k] + lst_happiness[i-1][k])
            # 結果をメモする
            dp[i][j] = res
    
    return dp[i]
ans = rec(vacation)
ans = max(ans)
print(ans)

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

int main() {
    int a,b,d,r;
    double f;
    
    cin >> a >> b;
    
    d = a/b;
    r = a%b;
    f = (double) a/b;
    
    cout << d << " " << r << " " << fixed << f << endl;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,a[403];
ll num[403],dp[403][403];
int main(){
	read(n);
	for (int i=1;i<=n;i++)read(a[i]),num[i]=num[i-1]+a[i];
	for (int k=2;k<=n;k++)
		for (int i=1;i+k-1<=n;i++){
			int j=i+k-1;
			dp[i][j]=1e18;
			for (int l=i;l<j;l++) dp[i][j]=min(dp[i][j],dp[i][l]+dp[l+1][j]);
			dp[i][j]+=num[j]-num[i-1];
		}
	write(dp[1][n]);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int prime[N], cnt;bool st[N];
void init() {
    st[0] = st[1] = true;
    for(int i = 2; i < N; i++) {
        if(!st[i])  prime[cnt++] = i;
        for(int j = 0; j < cnt && i * prime[j] < N; j++) {
            st[i * prime[j]] = true;
            if(i % prime[j] == 0)   break;
        }
    }
}
int main() {
    init();
    int n, sum;
    while(cin >> n) {
        sum = 0;
        for(int i = 2; i <= n; i++)
            if(!st[i])
                sum++;
        cout << sum << endl;
    }
}


Measured memory_bytes: 4284
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 3e4 + 5;
const int M = 1e6 + 5;
const int Mod = 1e9 + 7;

int main()
{
	GO;
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll ans = 0;
	for (auto& i : s)
		i = (i == 'R') + (i == 'R' || i == 'G');
	for (int i = 0; i < n; i++)
	{
		int cnt[3] = { 0,0,0 };
		for (int j = i + 1; j < n; j++)
		{
			int mid = i + j >> 1;
			if ((i + j) % 2 == 0)
				cnt[s[mid]]--;
			int ai = s[i], aj = s[j];
			if (ai > aj)
				swap(ai, aj);
			if (ai == 0)
			{
				if (aj == 1)
					ans += cnt[2];
				else if (aj == 2)
					ans += cnt[1];
			}
			else if (ai == 1 && aj == 2)
				ans += cnt[0];
			if ((i + j) % 2 == 0)
				cnt[s[mid]]++;
			cnt[s[j]]++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
/*
    Zeolim - An AC a day keeps the bug away
*/
  
//#pragma GCC optimize(2)
//#pragma GCC ("-W1,--stack=128000000")
#include <bits/stdc++.h>
using namespace std;
#define mp(x, y) make_pair(x, y)
#define fr(x, y, z) for(int x = y; x < z; ++x)
#define pb(x) push_back(x)
#define mem(x, y) memset(x, y, sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair <int, int> pii;
typedef std::vector <int> vi;
void re(ll &x){x=0;char s=getchar();while(s<'0'||s>'9')s=getchar();while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}}
void wr(ll x){if(x>9) wr(x/10);putchar(x%10+'0');}
const ld PI = acos(-1.0);
const ld E = exp(1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 386910137;
const ull P = 13331;
const int MAXN = 1e6 + 100;
 
ld a, b, x, y;
 
ld to(ld x) { return (x / 180.0) * PI; }
ld ret(ld x) { return x / PI * 180.0; }
 
ld cal(ld deg)
{
	if(deg >= y)
	{
		ld rb = a * tan(PI / 2.0 - deg) ;
		return a * b * a - a * rb / 2.0 * a;
	}
	else
	{
		ld ra = b * tan(deg);
		return (b * ra / 2.0 * a);
	}
}
 
 
int main()
{  
    //ios::sync_with_stdio(0);
    //cin.tie(0); cout.tie(0);
    //freopen("d:\out.txt","w",stdout);
    //freopen("d:\in.txt","r",stdin);  
  	
  	cin >> a >> b >> x;
  	
  	y = atan(a/b);
  	
  	ld fst = 0, lst = PI / 2.0, mid;
  	
  	for(int i = 0; i < 1000; ++i)
  	{
  		mid = (fst + lst) / 2.0;
  		
  		if(cal(mid) >= x)
  			lst = mid;
  		else
  			fst = mid;
	}
	  
	cout << fixed << setprecision(10) << 90.0 - mid / PI * 180.0 << '\n';
    
    return 0;
}


Measured memory_bytes: 384
N, K = map(int,input().split(' '))
A = []
for i in range(N):
    a,b = map(int,input().split(' '))
    A.append([a,b])

A.sort()
cnts=0
vals=0
for i in range(len(A)):
    cnts+=A[i][1]
    vals=A[i][0]
    if cnts>=K:
        print(vals)
        exit(0)

#print(A)

Measured memory_bytes: 20104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}


int n,m;
vector<P> vec(10000);
int rec(int x, auto reached){
  int t=0;
  reached[x] = true;
  bool r2[10];
  REP(i,n+1){
    r2[i] = reached[i];
  }
  bool chk=true;
  REP(i,n+1){
    if (i!=0){
      if (!r2[i]){
        chk = false;
      }
    }
  }
  if (chk){return 1;}
  REP(i,m){
    bool r[10];
    REP(i,n+1){
      r[i] = reached[i];
    }
    int f = vec.at(i).first;
    int s = vec.at(i).second;
    if (vec.at(i).first == x){
      if (!r[vec.at(i).second]){
        t += rec(vec.at(i).second, r);
      }
    } else if (vec.at(i).second == x){
      if (!r[vec.at(i).first]){
        t += rec(vec.at(i).first, r);
      }
    }
  }
  return t;
}

int main(){
  cin >> n >> m;
  bool reached[10];
  REP(i,10){
    reached[i] = false;
  }
  REP(i,m){
    cin >> vec.at(i).first >> vec.at(i).second;
  }
  int t = rec(1,reached);
  cout << t << endl;
  return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
#define a_macro(args...) sum(args)
#define mp make_pair
#define eb emplace_back
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9+7;


int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n,i;
    cin>>n;
    ll k;
    cin>>k;
    vector<int> a(n+1);
    for(i=1;i<=n;++i)
    	cin>>a[i];

    vector<int> visited;
    map<int,bool> mp;
    i = 1;
    while(1){
    	if(mp[i])
    		break;
    	visited.push_back(i);
    	mp[i] = true;
    	i = a[i];
    }
    int te = 0;
    while(visited[te] != i) te++;
    if(k > te){
    	k -= (te);
    	int tt = visited.size() - te;
    	ll r = k%tt;
    	cout<<visited[te + r]<<"\n";
    }
    else
    	cout<<visited[k]<<"\n";
    
#ifndef LOCAL_DEFINE
    cerr << "Time elapsed: "<< 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
    return 0;
}

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

const int INF = 1001001001;
int main(){
  int N,L;
  cin>>N>>L;
  vector<string>S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  string ans=S.at(0);
  for(int i=1;i<N;i++){
  ans+=S.at(i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())

if len(set(list(s))) == 1:
    print(len(s)*k//2)
    exit()

tmp = []
cnt = 1

for i in range(1, len(s)):
    if s[i] == s[i-1]:
        cnt += 1
    else:
        tmp.append(cnt)
        cnt = 1

tmp.append(cnt)

if s[0] != s[-1]:
    ans = [i//2 for i in tmp]
    print(sum(ans) * k)
else:
    a = tmp[0]//2
    b = (tmp[0] + tmp[-1])//2
    c = tmp[-1]//2
    ans = [i//2 for i in tmp[1:-1]]
    print(a+sum(ans)*k+b*(k-1)+c)

Measured memory_bytes: 9176
#include <iostream>

using namespace std;

int main(){
  char img[103][103];
  char c;
  int h, w;
  cin >> h >> w;
  for(int i=0; i<h+2; i++)
    for(int j=0; j<w+2; j++){
      if(i==0 || i==h+1 || j==0 || j==w+1) img[i][j]='#';
      else {
	cin >> c;
	img[i][j] = c;
      }
    }
  
  for(int i=0; i<h+2; i++){
    for(int j=0; j<w+2; j++){
      cout << img[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

"""考え方
左から、小さい順に数字を取得する。
これで得られる最大の値とレンガの個数の差分が答え。
ただし、「1」が無い場合は「-1」となる。
"""

pre_num = 0
for n in range(0,N,1):
  if A[n] == pre_num+1:
    pre_num = A[n]

if pre_num == 0:
  ans = -1
else:
  ans = N - pre_num

print(ans)

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<int> q = {a, b, c, d};
    sort(q.begin(), q.end());

    if(q.at(0) == q.at(1) && q.at(2) == q.at(3)){
        cout<<"yes"<<endl;
    }else{
        cout<<"no"<<endl;
    }
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#include <map>
#include <limits.h>
#include <unordered_set>
#include <stack>
#include <string.h>
#include <math.h>
#define fo(i,l,r) for(int i=l;i<=r;++i)
#define fi(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define po pop_back
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long int ll;
typedef unsigned long long int ulli;
using namespace std;
void generatePrimes(){

}
void swap(int *a,int *b){
    int tmp = *a;
    *a = *b;
    *b = tmp;
}
void input(vector<int>& arr,int n){
    fo(i,0,n-1){
        cin>>arr[i];
    }
}
void input(vector<ll>& arr,int n){
  fo(i,0,n-1){
    cin>>arr[i];
  }
}
void input(vector<ulli>& arr,int n){
    fo(i,0,n-1){
        cin>>arr[i];
    }
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ulli max(ulli a,ulli b){
    return a>b?a:b;
}
int max(int a,int b){
    return a>b?a:b;
}
void print(vector<int>& ans,int n){
    fo(i,0,n-1){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}
void print(vector<ll>& ans,int n){
    fo(i,0,n-1){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}
void solve(){
    ll s,w;
    cin>>s>>w;
    if(w>=s){
      cout<<"unsafe"<<endl;
    }
    else{
      cout<<"safe"<<endl;
    }
}
int main(){
    speed;
    solve();
}


Measured memory_bytes: 3056
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  int _n = n / 2;
  unordered_map<int, int> M0;
  unordered_map<int, int> M1;
  for (int i = 0; i < n; ++i) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      ++M0[v];
    } else {
      ++M1[v];
    }
  }
  vector<vector<int>> V0;
  for (auto &m : M0) {
    V0.push_back(vector<int>{m.second, m.first});
  }
  vector<vector<int>> V1;
  for (auto &m : M1) {
    V1.push_back(vector<int>{m.second, m.first});
  }
  sort(V0.begin(), V0.end());
  sort(V1.begin(), V1.end());
  int N0 = V0.size();
  int N1 = V1.size();
  if (V0[N0 - 1][1] == V1[N1 - 1][1]) {
    if (N0 == 1 && N1 == 1) {
      printf("%d\n", _n);
    } else if (V0[N0 - 1][0] == V1[N1 - 1][0]) {
      if (V0[N0 - 2][0] <= V1[N1 - 2][0]) {
        printf("%d\n", abs(V0[N0 - 1][0] - _n) + abs(V1[N1 - 2][0] - _n));
      } else {
        printf("%d\n", abs(V0[N0 - 2][0] - _n) + abs(V1[N1 - 1][0] - _n));
      }
    } else {
      if (V0[N0 - 1][0] < V1[N1 - 1][0]) {
        printf("%d\n", abs(V0[N0 - 2][0] - _n) + abs(V1[N1 - 1][0] - _n));
      } else {
        printf("%d\n", abs(V0[N0 - 1][0] - _n) + abs(V1[N1 - 2][0] - _n));
      }
    }
  } else {
    printf("%d\n", abs(V0[N0 - 1][0] - _n) + abs(V1[N1 - 1][0] - _n));
  }
}

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

using namespace std;


signed main() {

    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    char s[4];

    for(int i = 0; i < 4; i++) { 
        char ch = getchar();
        s[i] = ch;
    }

    sort(s, s + 4);

    if(s[1]==s[0] && s[2] != s[1] && s[3] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const int MAX_N = 100010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow_mod(fact[n],-1);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    if (b > a) return 0;
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

ll permu(ll a,ll b) {
    if (b > a) return 0;
    return fact[a]*fact_inv[a-b]%mod;
}

int n,k;
ll ans;
vector<int> G[100010];

void dfs(int i,int p = -1) {
    int c = G[i].size(),d = 1;
    if (p > -1) {
        c--;
        d++;
    }
    (ans *= permu(k-d,c)) %= mod;
    for (int j : G[i]) if (j != p) dfs(j,i);
}

int main() {
    create_table(100010);
    cin >> n >> k;
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ans = k;
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11520
import math

lst = []
n = int(input())
dis_sum = 0
for i in range(n):
  a,b = map(int,input().split())
  lst.append([a,b])
for i in lst:
  for j in lst:
    x = abs(j[0]-i[0])
    y = abs(j[1]-i[1])
    dis_sum += math.sqrt(x**2 + y**2) 
print(dis_sum / n)                           


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

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

  string alpha = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < alpha.length(); i++)
  {
    if (s.find(alpha[i]) == string::npos)
    {
      cout << alpha[i] << endl;
      return 0;
    }
  }

  cout << "None" << endl;
}

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

int main(int argc, char const *argv[]) {
  char N[9];
  int s = 0;
  scanf("%s", N);
  for (int i = 0; N[i] != 0; i++) {
    s += (N[i] - '0');
  }
  int n = std::atoi(N);
  if (n % s == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
l, r = list(map(int, input().split()))
mod = 2019

flg = False

for i in range(l, (r + 1), 1):
    if ((i % mod) == 0):
        flg = True
        break

if (flg):
    print(0)
else:
    ans = 2019

    for i in range((l % mod), (r % mod), 1):
        for j in range(((l % mod) + 1), ((r % mod) + 1), 1):
            rep = (i * j) % mod

            if (rep < ans):
                ans = rep

    print(ans)


Measured memory_bytes: 40172
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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

int main(){

	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
		&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)){
			if(xb2 < xa1 || xa2 < xb1 || yb1 > ya2 || yb2 < ya1){
				cout << "NO" << endl;
			}
			else{
				cout << "YES" << endl;
			}
	}
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs();
            var count = 0;
            while (A.All(x => x % 2 == 0))
            {
                count++;
                A = A.Select(x => x / 2).ToList();
            }
            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

int main() {
    ll n, ans = 0; cin >> n;

    vector<ll> num(n+1, 0);
    frep(i, 1, n) {
        for(ll j = i; j <= n; j += i) {
            num[j]++;
        }
    }
    frep(i, 1, n) {
        ans += (i*num[i]);
    }

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


Measured memory_bytes: 81400
#include <iostream>
#include <vector>

using namespace std;

int main(){

    char moji[6];
    for(int i=0; i<6; i++){
        cin >> moji[i];
    }

    if(moji[0] == moji[5] && moji[1] == moji[4] && moji[2] == moji[3]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(_) for _ in input().split()]

c = 0
for i in range(n):
    minj = i
    for j in range(i+1, n):
        if A[j] < A[minj]:
            minj = j
    t = A[i]
    A[i] = A[minj]
    A[minj] = t
    if i != minj:
        c += 1
print(' '.join(map(str, A)))
print(c)


Measured memory_bytes: 5604
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

int prime[3500];
int find_prime();
int prime_search(int, int, int, int);

int main()
{
    int limit = find_prime();

    int n;
    scanf("%d", &n);
    int end = int(sqrt(n * 1.0)) + 1;
	int phi = n;

    for(int i = 0; prime[i] < end; i++){
        if(n % prime[i] == 0){
            do{ n = n / prime[i]; }while(n % prime[i] == 0);
            phi /= prime[i];
            phi *= (prime[i] - 1);
        }
        if(n == 1) break;
    }
    if(n > 1){ phi /= n; phi *= (n - 1); }

    printf("%d\n", phi);

    return 0;
}

int find_prime()
{
    int n, lim;
    prime[0] = 2, prime[1] = 3, prime[2] = 5, prime[3] = 7;
    n = lim = prime_search(4, 2, 32, 0);
    n = lim = prime_search(n, 32, 180, lim);
    return prime_search(n, 180, 31700, lim);
}

int prime_search(int n, int from, int to, int lim)
{
    int i, j;
    for(i = from; i < to; i++){
        if(i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0) continue;
        for(j = 0; j < lim; j++){
            if(i % prime[j] == 0) break;
        }
        if(j == lim){ prime[n] = i; n++; }
    }
    return n;
}

Measured memory_bytes: 1196
k = int(input())
a, b = map(int, input().split())
ka = a // k
kb = b // k
if b - a >= k - 1:
  print("OK")
elif kb - ka > 0:
  print("OK")
elif a % k == 0 or b % k == 0:
  print("OK")
else:
  print("NG")


Measured memory_bytes: 9060
// Problem : C - Tax Increase
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int a, b;
    cin >> a >> b;
    
    for (int i=10*b; i<10*(b+1); i++)
        if (i * 2 / 25 == a) {
            cout << i << "\n";
            return 0;
        }
    cout << "-1\n";

    return 0;
}


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

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

using namespace std;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main() {
 
    int n;
    cin >> n;
    
    vector<int> v(n);
    vector<int> v_tmp(n,0);

    int i,j,tmp,count;
    tmp = 1000000; count = 0;
    
    for(i=0;i<n;i++){
        cin >> v[i];
        v_tmp[i] = min(tmp,v[i]);
        tmp = v_tmp[i];
    }
    
    for(i=0;i<n;i++){
        //cout << v_tmp[i] << v[i] << endl ;  
        if(v_tmp[i] >= v[i]) count++;
    }

    cout << count <<endl ;

}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int n,i,j,k,l;
    int dice[24][6];
    int label[24][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
    {2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},{4,1,5,2,6,3},
    {4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
    {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}};
    
    scanf("%d",&n);
    int dices[n][6];
    
    for(i=0;i<n;i++){
        for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
    }
    
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) dice[k][l]=dices[j][label[k][l]-1];
            }
            
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) {
                    if(dice[k][l]!=dices[i][l]) {
                        break;
                    }
                }
                if(l==6){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2108
/* B - Minor Change */

#include <bits/stdc++.h>
using namespace std;

int main(){
  string S, T;
  int cnt = 0;
  cin >> S >> T;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) != T.at(i)) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	string s,t;
	cin>>s>>t;
	int ans=0;
	rep(i,3){
		if(s[i]==t[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func main() {
	var K, A, B int
	fmt.Scanf("%d\n%d %d\n", &K, &A, &B)
	ok := false
	for i := A; i <= B; i++ {
		if i%K == 0 {
			ok = true
		}
	}
	if ok {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}

}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 1816
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,m,x; cin >>n>>m>>x;
    vector<int> a(n+1);
    for (int i = 0; i < m; i++) {
        int j; cin >> j;
        a[j] = 1;
    }

    int resl = 0, resr = 0;
    for (int i = 0; i < n+1; i++) {
        if(i < x) {
            resl += a[i];
        } else if(x < i) {
            resr += a[i];
        }
    }

    cout << min(resl, resr) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <list>

#define nullptr NULL

int main(void)
{
    std::string str;
    std::list<int> datas;

    int commandNum = 0;
    std::getline(std::cin, str);
    commandNum = atoi(str.c_str());

    for (int i = 0; i < commandNum; i++) {
        int keyValue = 0;
        std::string command;
        std::getline(std::cin, str);
        std::string::size_type space = str.find(' ');
        if (space == std::string::npos) {
            command = str;
        } else {
            command = str.substr(0, space);
            keyValue = atoi(str.substr(space + 1).c_str());
        }

        if (command.at(0) == 'i') {
            datas.push_front(keyValue);
        } else if (command[0] == 'd' && command.length() <= 6) {
            for (std::list<int>::iterator it = datas.begin(); it != datas.end(); it++) {
                if (*it == keyValue) {
                    datas.erase(it);
                    break;
                }
            }
        } else if (command.at(0) == 'd' && command.at(6) == 'F') {
            datas.pop_front();
        } else if (command.at(0) == 'd' && command.at(6) == 'L') {
            datas.pop_back();
        }
    }

    bool addSpace = false;
    for (std::list<int>::iterator it = datas.begin(); it != datas.end(); it++) {
        if (addSpace) {
            printf(" ");
        }
        printf("%d", *it);
        addSpace = true;
    }
    printf("\n");

    return 0;
}



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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;
ll n, a[N];
ll b[N];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	ll k;
	cin >> k;
	n = 50;
	ll f = k % n;
	ll ost = f;
	k /= n;
	fo(i, n)
		if(f)
			a[i] = k + ost + 1, f--;
		else 
			a[i] = k;
	cout << n << '\n';
	fo(i, n)
	{
		a[i] += n - ost - 1;
		cout << a[i] <<' ';
	}
	return 0;
}

Measured memory_bytes: 256
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


s = input()
#a = list(map(int, input().split()))

mode=0
ans=0
anum=0
banum=0
for i in range(len(s)):
    if(mode==0 and s[i]=='A'):
        anum+=1
    elif(mode==1 and s[i]=='A'):
        anum=1
        mode=0
    elif(mode==0 and s[i]=='B'):
        mode=1
    elif(mode==1 and s[i]=='B'):
        mode=0
        anum=0
    elif(mode==0 and s[i]=='C'):
        mode=0
        anum=0
    elif(mode==1 and s[i]=='C'):
        mode=0
        ans += anum
    #print(ans)

print(ans)


Measured memory_bytes: 40928
N, A, B = tuple(map(int, input().split()))
i = 0
while True:
    if i % 2 == 0:
        if A + 1 != B:
            A += 1
        else:
            A -= 1
    else:
        if B - 1 != A:
            B -= 1
        else:
            B += 1
    if A < 1:
        print("Borys")
        break
    if B > N:
        print("Alice")
        break
    i += 1


Measured memory_bytes: 3060
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso

  ll n; cin >> n;
  cout << (long long)n+(n*n)+(n*n*n) <<endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S, T;
  cin >> S >> T;
  int Q; cin >> Q;

  int NS = SZ(S), NT = SZ(T);
  VI as(NS+1), bs(NS+1), at(NT+1), bt(NT+1);
  REP(i,NS){
	as[i+1] = as[i] + (S[i] == 'A');
	bs[i+1] = bs[i] + (S[i] == 'B');
  }
  REP(i,NT){
	at[i+1] = at[i] + (T[i] == 'A');
	bt[i+1] = bt[i] + (T[i] == 'B');
  }
  
  while(Q--){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	--a;
	--c;
	int ns = as[b] - as[a] + (bs[b] - bs[a]) * 2;
	int nt = at[d] - at[c] + (bt[d] - bt[c]) * 2;
	cout << (ns%3 == nt%3 ? "YES": "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 2640
a,b = [int(x) for x in input().split()]
s1 = ''
s2 = ''
for i in range(a):
	s1 = s1 + str(b)
for i in range(b):
	s2 = s2 + str(a)
n1 = int(s1)
n2 = int(s2)
if (n1>=n2):
	print(n1)
else :
	print(n2)

Measured memory_bytes: 3064
a = input().split(" ")
a = [int(i) for i in a]

if a[0] + a [1] <= 0 or a[0] * a[1] <= 0:
  print(-1)
  
else:
  if a[0] >= 10 or a[1] >= 10:
    print(-1)
  else:
    print(a[0] * a[1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi num(100000);vi a(N);rep(i,N){cin>>a[i];num[a[i]]++;}
  vi wa(100000);wa[0]=num[0];
  for(int i=1;i<100000;i++){
    wa[i]=wa[i-1]+num[i];
  }
  int ans=0;
  for(int i=0;i<=99997;i++){
    ans=max(ans,wa[i+2]-wa[i-1]);
  }
  cout<<ans<<endl;
  
  
}







Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

bool dp[8010][10000 * 2] = {};
bool dp2[8010][10000 * 2] = {};

int main(){
	string s; cin >> s;
	int x, y; cin >> x >> y;
	
	vector<int> vec[2]; bool f = false; vec[0].push_back(0);
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'T'){
			f = !f;
			vec[f].push_back(0);
		}else{
			vec[f].back()++;
		}
	}
	
	dp[0][10000] = dp2[0][10000] = true;
	for(int i = 0; i < vec[0].size(); i++){
		for(int j = 0; j < 10000 * 2; j++){
			if(j + vec[0][i] < 10000 * 2) dp[i + 1][j + vec[0][i]] |= dp[i][j];
			if(i and j - vec[0][i] >= 0 ) dp[i + 1][j - vec[0][i]] |= dp[i][j];
		}
	}
	
	for(int i = 0; i < vec[1].size(); i++){
		for(int j = 0; j < 10000 * 2; j++){
			if(j + vec[1][i] < 10000 * 2) dp2[i + 1][j + vec[1][i]] |= dp2[i][j];
			if(j - vec[1][i] >= 0		) dp2[i + 1][j - vec[1][i]] |= dp2[i][j];
		}
	}
	
	if(dp[vec[0].size()][10000 + x] and dp2[vec[1].size()][10000 + y]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


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

namespace adaptor = boost::adaptors;

int64_t N, T;
std::vector<int64_t> t;

void solve()
{
    std::cin >> N >> T;
    t.resize(N);
    for (auto& v : t) std::cin >> v;

    int64_t ans = 0;
    for (int64_t i = 0; i < N - 1; i++)
    {
        ans += std::min(t[i + 1] - t[i], T);
    }
    ans += T; // 最後の1回
    std::cout << ans << std::endl;
}

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


Measured memory_bytes: 4692
#include <stdio.h>

int main(){
	int up_h, up_m, gt_h, gt_m, stu_m, all_m;

	scanf("%d %d %d %d %d", &up_h, &up_m, &gt_h, &gt_m, &stu_m);

	all_m = ((gt_h - up_h)*60)+(gt_m - up_m);

	printf("%d",all_m-stu_m);
	return 0;
}


Measured memory_bytes: 1732
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		d[i] = nextInt(sc)
	}
	sort.Ints(d)
	l := d[n/2-1]
	r := d[n/2]
	if l == r {
		fmt.Println(0)
	} else {
		fmt.Println(r - l)
	}
}


Measured memory_bytes: 2048
use strict;
use warnings;

main();

sub main{
	my $A = <STDIN>;
	my $B = <STDIN>;
	my $C = <STDIN>;
	my $X = <STDIN>;

	my $cnt = 0;

	for(my $a=0; $a<=$A; $a++){
		for(my $b=0; $b<=$B; $b++){
			for(my $c=0; $c<=$C; $c++){
				my $total = 500*$a + 100*$b + 50*$c;
				if($total == $X){ $cnt++;}
			}
		}
	}
	
	print "$cnt\n" ;
	1;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

constexpr int64_t mod = 1000000000 + 7;
int64_t dp[65][4] = {};

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

    dp[0][0] = 1ll;
    for(int i = 0; i < 64; ++i){
        for(int j = 0; j <= 2; ++j){
            for(int x = 0; x < 2; ++x){
                for(int y = x; y < 2; ++y){
                    int64_t b = (N >> i) & 1;
                    dp[i+1][(x+y+j-b+1)/2] = (dp[i+1][(x+y+j-b+1)/2] + dp[i][j]) % mod;
                }
            }
        }
    }
    cout << dp[64][0] << endl;
}

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

const int MAXN = 100010;
int h[MAXN], dp[MAXN];
int n, k;

int calc(int pos) {
    if(pos == n) return 0;
    int &y = dp[pos];
    if(y != -1) return y;
    y = calc(pos+1) + abs(h[pos] - h[pos+1]);
    for(int i=pos+2; i<=min(n, pos+k); ++i) {
        y = min(y, calc(i) + abs(h[pos] - h[i]));
    }
    return y;
}

int main() {
    memset(dp, -1, sizeof(dp));
	cin >> n >> k;
	for(int i=1; i<=n; ++i) {
	    cin >> h[i];
	}
	cout<<calc(1)<<endl;
	return 0;
}


Measured memory_bytes: 9056
a, b, c, d = [int(i) for i in input().split()]

def battle(a, b, c, d):
    i = 1
    while True:
        if i % 2 == 0:
            a -= d
            if a <= 0:
                return 'No'
        else:
            c -= b
            if c<= 0:
                return 'Yes'
        i += 1


print(battle(a, b, c, d))


Measured memory_bytes: 9176
#n=int(input())
#n,m=map(int,input().split())
#a=list(map(int,input().split()))
#q:グラフ探索済み格納キュー n:キューの次探索インデックス l:キュー内の次格納インデックス
def bfs_len_max(ind,graph,q_num):
    distance_arr=[0 if i==ind  else -1 for i in range(len(graph))]
    q=[-1 for _ in range(q_num)]
    q[0]=ind
    l=1
    n=0
    while len(q)>l:
        for i in graph[ind]:
            if distance_arr[i]==-1:
                distance_arr[i]=distance_arr[ind]+1
                q[l]=i
                l+=1
        #print(n)
        #print("elapsed q:",q)
        #print("elapsed distance:",distance_arr)
        #print()
        n+=1
        ind=q[n]


    return distance_arr
    

n,x,y=list(map(int,input().split()))
#n,x,y=[2*(10**3),1,3]


q_num=n
graph=[[1]]
for i in range(1,n-1):
    graph.append([i-1,i+1])
graph.append([n-2])
graph[x-1].append(y-1)
graph[y-1].append(x-1)
ans=[0 for _ in range(n)]

for s in range(n):
    if len(graph[s])==0:
        continue
    #print("ind:",s)
    tmp=bfs_len_max(s,graph,q_num)
    for each in tmp:
        ans[each]+=1
    #print("\n\n\n\n")

for each in ans[1:]:
    print(each//2)

Measured memory_bytes: 53468
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()0
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!

int _count(int n){
    int c=0;
    while(n>0 and n%2==0){
        c++;
        n/=2;
    }
    return c;
}
// int _count(int n){
//     int c=0;
//     for(int i=0;pow(2,i)<=n;i++){
//         c+=(n/pow(2,i));
//     }
//     return c;
// }

// actually we just have to find out the largest power of two less than or equal to the given number
// binary search is not applicable here.
bool isPowerOfTwo(int n){
    return n && !(n&(n-1));
}
bool getKthBit(int n,int k){
    return n&(1<<k);
}
int clearBit(int n,int k){
    return n = n & (~(1<<k));
    // return (n & (~(1 << k)));
}
void solve(){
    int n;
    cin>>n;
    
    bool f=0;
    for(int i=31;i>=0;i--){
        int b=getKthBit(n,i);
        if(b==1){
            if(f==0){
                f=1;
                continue;
            }
            else{
                n=clearBit(n,i);
                // cout<<n<<" ";
            }
        }
    }
    cout<<n<<endl;
}

 
int main() {
    faster;
    int t=1;
    // cin>>t;
    
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3588
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = lines[0]-0;
    const map = [];
    for(let i=1;i<=N;i++){
        map[i] = lines[i];
    }
    const chk = {};
    let p = 1;
    let ans = 0;
    while(p!=2){
        chk[p] = true;
        p = map[p];
        if(chk[p]){
            ans = -1;
            break;
        }
        ans++;
    }
    console.log(ans);
});

min = (...a)=>{return a.reduce((a,b)=>a<b?a:b, a[0])};


Measured memory_bytes: 46476
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
	int n, s[1000];
	int i;
	double A, a, m, sum;
	cin >> n;
	while (n != 0)
	{
		sum = 0;
		for (i = 0; i < n; i++)
		{
			cin >> s[i];
			sum += s[i];
		}
		m = sum / n;

		sum = 0;
		for (i = 0; i < n; i++)
		{
			sum += (s[i] - m) * (s[i] - m);
		}
		A = sum / n;
		a = sqrt(A);

		cout << fixed << setprecision(6) << a << endl;

		cin >> n;
	}
	return 0;
}


Measured memory_bytes: 3304
/*
   Username : moondancer
   Name : Moon Dancer
*/


#include <bits/stdc++.h>
using namespace std;

#define int long long
const int mod = 1000000007; 
#define MAX 10000003 
int prime[MAX]; 
unordered_map<int, int> max_map; 
  
// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
int lcmModuloM(const int* ar, int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
int ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.first, it.second)) % mod; 
    } 
  
    return ans; 
}
signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int f=0;
    int n;
    sieve();
    cin>>n;
    int a[n];
    int g=0;
    int x1=1;
    for (int i = 0; i < n; ++i){
        cin>>a[i];
        g=__gcd(g,a[i]);
        x1=(x1*a[i])%mod;
    }
    int x2=lcmModuloM(a,n);
    if(x1==x2) cout<<"pairwise coprime";
    else if(g==1) cout<<"setwise coprime";
    else cout<<"not coprime";
    return 0;
}

Measured memory_bytes: 92412