akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args)
	{
		FastScanner in=new FastScanner();
		int n=in.nextInt();
		int x=in.nextInt();
		int t=in.nextInt();
		int count=0;
		while(n!=0)
		{
			n-=Math.min(x, n);
			count++;
		}
		System.out.println(count*t);
	}

static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32800
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    ll N;
    cin >> N;
    string alphabets = "abcdefghijklmnopqrstuvwxyz";
    string ans;
    
    while (N > 26){
        ans += alphabets[(N-1)%26];
        N -= (N-1)%26;
        N /= 26;
    }
    ans += alphabets[(N-1)%26];
    reverse(all(ans));
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (5000)
#define MOD (998244353)

char s[MAXN+1];
int dp[MAXN+1][MAXN+1];

int main(void)
{
    int n;
    scanf("%d",&n);
    scanf("%s",s);

    int ans = 0;
    for(int i=n-1;i>=0;i--) for(int j=n-1;j>=0;j--)
    {
        if(s[i]==s[j])
        {
            dp[i][j] = dp[i+1][j+1]+1;
            int score = min(abs(i-j),dp[i][j]);
            ans = max(ans, score);
        }
    }
 
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 97792
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

char a[1005][1005];
ll dp[1005][1005];


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, m; cin >> n >> m;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	dp[1][1] = 1;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			if (a[i][j - 1] != '#')dp[i][j] += dp[i][j - 1];
			if (a[i - 1][j] != '#')dp[i][j] += dp[i - 1][j];
			dp[i][j] %= mod;
		}
	}

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

	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 9088
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
//orz mqy
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const int c[]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if (a==b){
		printf("Draw\n");
	}
	else if (c[a]>c[b]){
		printf("Alice\n");
	}
	else{
		printf("Bob\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
using namespace std;
using LL = long long;

int main(){
    string s;cin>>s;
    
    //00
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){cout<<i+1<<" "<<i+2<<endl;return 0;}
    }
    //010
    for(int i=0;i<s.size()-2;i++){
        if(s[i]==s[i+2]){cout<<i+1<<" "<<i+3<<endl;return 0;}
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

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

char buf[50];
int main() {
	ll s;
	int d; cin >> d;
	rep(j, d) {
		cin >> s;
		printf("Case %d:\n", j + 1);
		rep(i, 10) {
			s *= s;
			sprintf(buf, "%08lld", s);
			string ans(buf);
			cout << (s = stoi(ans.substr(2, 4))) << endl;
		}
	}
}

Measured memory_bytes: 3272
#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 = INF * (LL) INF;

int a[5];
int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(0);
    FOR(i,0,3)
    {
        cin >> a[i];
    }
    sort(a, a + 3);
    cout << a[0] + a[1];
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		Queue<String> qProcess = new LinkedList<String>();
		Queue<Integer> qTime = new LinkedList<Integer>();
		
		int totalTime = 0;
		
		for (int i = 0; i < n; i++) {
			qProcess.add(sc.next());
			qTime.add(sc.nextInt());
		}
		
		while (qProcess.size()>0) {
			if (qTime.peek() - q > 0) {
				qProcess.add(qProcess.poll());
				qTime.add(qTime.poll()-q);
				totalTime = totalTime + q;
			} else {
				totalTime = totalTime + qTime.poll();
				System.out.println(qProcess.poll() + ' ' + totalTime);
			}
		}
	}
}


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

using namespace std;

int tbl[10000 + 1] = {0};

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

    for(long long x = 1; x <= 100; x++){
        for(long long y = 1; y <= 100; y++){
            for(long long z = 1; z <= 100; z++){
                long long res = x * x + y * y + z * z + x * y + y * z + z * x;
                if(res > N) continue;
                ++(tbl[(int)res]);
            }
        }
    }

    for(int i = 1; i <= N; i++){
        cout << tbl[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if b == a[i // 3][i % 3]:
            a[i // 3][i % 3] = 0
flag = False
if a[0][0] == a[0][1] == a[0][2] == 0:
    flag = True
if a[1][0] == a[1][1] == a[1][2] == 0:
    flag = True
if a[2][0] == a[2][1] == a[2][2] == 0:
    flag = True
if a[0][0] == a[1][0] == a[2][0] == 0:
    flag = True
if a[0][1] == a[1][1] == a[2][1] == 0:
    flag = True
if a[0][2] == a[1][2] == a[2][2] == 0:
    flag = True
if a[0][0] == a[1][1] == a[2][2] == 0:
    flag = True
if a[0][2] == a[1][1] == a[2][0] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    rep(x,50010) {
        if(floor((double)x*1.08)==n) {
            cout<<x<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

typedef map<int, int> P;

int in[10], n, idx;
string str;

P solve(){
  P res;
  if('0' <= str[idx] && str[idx] <= '9'){
    res[in[str[idx++]-'1']]++;
    return res;
  }
  idx++;
  P l = solve();
  idx++;
  P r = solve();
  idx++;
  for(P::iterator i=l.begin();i!=l.end();i++){
    for(P::iterator j=r.begin();j!=r.end();j++){
      int bl = i->first;
      int br = j->first;
      res[bl & br] += i->second * j->second;
      res[bl | br] += i->second * j->second;
      res[bl ^ br] += i->second * j->second;
    }
  }
  return res;
}

main(){
  while(getline(cin, str) && str != "END"){
    cin >> n;
    for(int i=0;i<n;i++){
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      in[i] = 0;
      if(a) in[i] += 1<<3;
      if(b) in[i] += 1<<2;
      if(c) in[i] += 1<<1;
      if(d) in[i] += 1<<0;
    }
    getchar();
    idx = 0;
    P ans = solve();
    cout << ans[(1<<4)-1] << endl;
  }
}

Measured memory_bytes: 0
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8) << "\n";
	return 0;
}




Measured memory_bytes: 256
using System;

namespace ITP1_3_B
{
    class Program
    {
        static void Main()
        {
            for (int i = 1; i > 0; i ++)
            {
                int x = int.Parse(Console.ReadLine());
                if (x == 0) break;
                else Console.WriteLine("Case {0}: {1}", i, x);
            }

        }
    }
}



Measured memory_bytes: 17948
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll int N, a[5];
    cin >> N;
    rep(i, 5) cin >> a[i];
    sort(a, a + 5);

    if (N % a[0] != 0) cout << (N / a[0]) + 5 << endl;
    else cout << (N / a[0]) + 4 << endl;
}


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

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;
#define double long double

//INSERT ABOVE HERE
signed main(){
  Int n;
  double d,x;
  cin>>n>>d>>x;
  double ans=0;
  while(n){
    ans+=(2*d+(2*n-1)*x)/2;
    //cout<<ans<<endl;
    double nd=(2*n*d+2*d+5*x)/(2*n);
    double nx=((d+x)*(2*n-3)+(d+x*3)*2+3*(d+x*2))/(2*n)-nd;
    swap(d,nd);
    swap(x,nx);
    n--;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local N = io.read("n")
local lim = math.ceil(N^0.5)
local ans = 0
dbgpr(lim)
for k=lim,1,-1 do
    dbgpr(k)
    if N % k == 0 then
        local d = N // k
        local m = d - 1
        if m > 0 and (N // m == N % m) then
            dbgpr("OK", k, d, m)
            ans = ans + m
        end
    end
end
print(ans)

Measured memory_bytes: 760
n,m = map(int,input().split())

a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        #print(i,j)

        flg = True
        for ii in range(m):
            for jj in range(m):
                if a[i+ii][j+jj] != b[ii][jj]:
                    flg = False

        if flg == True:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll a, b;
    cin>>a>>b;
    cout<<max(a+b, max(a-b, a*b))<<endl;
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a,b,c,d;
int main(void)
{
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	ll t1 = b/c - (a-1)/c;
	ll t2 = b/d - (a-1)/d;
	ll gcd = c*d/__gcd(c,d);
	ll t3 = b/gcd - (a-1)/gcd;
	printf("%lld",(b-a+1) - t1-t2+t3);
	return 0;
}

Measured memory_bytes: 256
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

n,m = inpl()


if n ==m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4336
#include <unordered_set>
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A;
    std::unordered_set<int> others;
    int counts[1000001] = {0};
    for (int i = 0; i < N; ++i) {
        int a;
        std::cin >> a;
        A.push_back(a);
        others.insert(a);
        counts[a] += 1;
    }

    int ans = 0;
    for (int a : A) {
        bool del = false;
        if (counts[a] == 1) {
            others.erase(a);
            del = true;
        }
        bool ok = true;
        for (int i = 1; i * i <= a; ++i) {
            if (a % i == 0) {
                if (others.find(i) != others.end() ||
                    others.find(a / i) != others.end()) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) {
            ++ans;
        }
        if (del) {
            others.insert(a);
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 16132
from collections import deque
h,w=map(int,input().split())
S=[input() for _ in range(h)]
ans=0
inf=float("inf")
for i in range(h):
   for j in range(w):
      if S[i][j]=="#":
         continue
      else:
         dp=[[inf for _ in range(w)]for _ in range(h)]
         dp[i][j]=0
         que=deque([(i,j)])
         while que:
            si,sj=que.popleft()
            for ni,nj in [(si+1,sj),(si-1,sj),(si,sj+1),(si,sj-1)]:
               if 0<=ni<h and 0<=nj<w and S[ni][nj]!="#":
                  if dp[ni][nj]>dp[si][sj]+1:
                     dp[ni][nj]=dp[si][sj]+1
                     ans=max(ans,dp[si][sj]+1)
                     que.append((ni,nj))
print(ans)

Measured memory_bytes: 48220
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int dp[3][100005];

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

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

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < N; i++) {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
    }
    cout << max(max(dp[0][N-1], dp[1][N-1]), dp[2][N-1]) <<endl;

    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	vector<char> c(m);
	REP(i, m) cin >> a[i] >> c[i]; 
	rep(i, 0, 1000){
		string s = to_string(i);
		if(s.size() != n) continue;
		bool f = true;
		REP(j, m){
			if(s[a[j] - 1] != c[j]){
				f = false;
				break;
			}
		}
		if(f){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;
void input(){
    fast_io();
    cin >> S;
}

int solve(){
    int ans = 0;
    if(S[0]=='R' && S[1]=='R' && S[2]=='R') ans = 3;
    else if(S[0]=='R' && S[1]=='R' && S[2]=='S') ans = 2;
    else if(S[0]=='S' && S[1]=='R' && S[2]=='R') ans = 2;
    else if(S[0]=='R' || S[1]=='R' || S[2]=='R') ans = 1;
    else ans = 0;
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main(void)
{
    map<unsigned long long int, int> stat;
    int N = 0;
    int a = 0;

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

    map<unsigned long long int, int>::iterator it;
    for (it = stat.begin(); it != stat.end(); it++)
    {
        //cout << "stat[" << it->first << "] = " << it->second << endl;
    }

    unsigned long long  int squered = 0;
    unsigned long long int rect = 0;
    unsigned long long int w = 0, h = 0;

    map<unsigned long long int, int>::reverse_iterator rit;
    for (rit = stat.rbegin(); rit != stat.rend(); rit++)
    {
        if (rit->second >= 4 && squered == 0)
        {
            squered = rit->first * rit->first;
        }

        if (w == 0 && rit->second >= 2)
        {
            w = rit->first;
            continue;
        }

        if (w != 0 && h == 0 && rit->second >= 2)
        {
            h = rit->first;
            break;
        }
    }

    rect = w * h;
    //cout << w << " " << h << " " << squered << endl;

    cout.precision(30);
    if (squered > rect)
    {
        //cout << 1 << endl;
        cout << squered << endl;
    }
    else
    {
        //cout << 2 << endl;
        cout << rect << endl;
    }

    return 0;
}



Measured memory_bytes: 6528
class UnionFind():
    def __init__(self,n):
        self.parents=[-1]*n
    
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x==y:
            return
        
        if self.parents[x] > self.parents[y]:
            x,y=y,x
        
        self.parents[x]+=self.parents[y]
        self.parents[y]=x

N,M=map(int,input().split())
uf=UnionFind(N+1)
for _ in range(M):
    a,b=map(int,input().split())
    uf.union(a,b)
    
print(abs(min(uf.parents)))
    

Measured memory_bytes: 14644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N-K+1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,v,b,w,t,ans;
    scanf("%lld%lld",&a,&v);
    scanf("%lld%lld",&b,&w);
    scanf("%lld",&t);
    if(w>=v)
    {
        printf("NO\n");
    }
    else
    {
        if(b>a)
        {
            if((b-a)%(v-w)==0)
                ans=(b-a)/(v-w);
            else
                ans=1+(b-a)/(v-w);
        }
        else
        {
            if((a-b)%(v-w)==0)
                ans=(a-b)/(v-w);
            else
                ans=1+(a-b)/(v-w);
        }
        if(ans<=t)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1648
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,k;
            cin>>n>>k;
            int ar[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i];
            ll dp[n+1][k+1],dp2[n+1][k+1];
            mem(dp,0);
            mem(dp2,0);
            for(i=0;i<=k;++i)
                dp2[0][i]=1;
            for(i=1;i<=n;++i)
            {
                dp[i][0]=1;
                for(j=k;j>=1;--j)
                {
                    if(j-ar[i]-1>=0)
                        dp[i][j]=(dp2[i-1][j]-dp2[i-1][j-ar[i]-1]+mod)%mod;
                    else
                        dp[i][j]=dp2[i-1][j];
                }
                dp2[i][0]=1;
                for(j=1;j<=k;++j)
                {
                    dp2[i][j]=(dp2[i][j-1]+dp[i][j])%mod;
                    //cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<dp2[i][j]<<endl;
                }
            }
            cout<<dp[n][k]<<endl;
        }
        return 0;
    }


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i ++) {
    cin >> a.at(i);
  }

  vector<vector<char>> b(h + 2, vector<char>(w + 2));
  for (int i = 0; i < h + 2; i ++) {
    for (int j = 0; j < w + 2; j ++) {
      b.at(i).at(j) = '#';
    }
  }

  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) {
      b.at(i + 1).at(j + 1) = a. at(i).at(j);
    }
  }

  for (int i = 0; i < h + 2; i ++) {
    for (int j = 0; j < w + 2; j ++) {
      cout << b.at(i).at(j);
    }
    cout << endl;
  }
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, K;
ll A[200010], F[200010];
ll ans;

bool C(ll mid){//ここに条件を書く

	ll tmpK = K;
	REP(i,0,N){
		if(A[i] * F[i] <= mid) continue;
		tmpK -= A[i] - mid / F[i];
	}
    return tmpK >= 0;
}


ll Nibutan(ll lb, ll ub){
    while(ub-lb>1){
        ll mid=(lb+ub)/2;
        if(C(mid)) ub=mid;
        else lb=mid;
    }
    return ub;
}
int main(){
	cin >> N >> K;
	REP(i,0,N){
		cin >> A[i];
	}
	REP(i,0,N){
		cin >> F[i];
	}
	sort(A, A+N);
	sort(F, F+N);
	reverse(F, F+N);
	ans = Nibutan(-1, 1e12);
	p(ans);
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
ll a, b, c, x, y, ans;
void solve(){
}
int main(){
    cin >> x >> y >> a >> b >> c;
    vector<ll>an(a);
    vector<ll>bn(b);
    vector<ll>cn(c);
    for(int i = 0; i < a; i++){
        cin >> an.at(i);
    }
    for(int i = 0; i < b; i++){
        cin >> bn.at(i);
    }
    for(int i = 0; i < c; i++){
        cin >> cn.at(i);
    }
    sort(an.begin(), an.end());
    reverse(an.begin(), an.end());
    sort(bn.begin(), bn.end());
    reverse(bn.begin(), bn.end());
    sort(cn.begin(), cn.end());
    reverse(cn.begin(), cn.end());
    ans = 0;
    vector<int>xn(x);
    vector<int>yn(y);
    for(int i = 0; i < x; i++){
        xn.at(i) = an.at(i);
    }
    for(int i = 0; i < y; i++){
        yn.at(i) = bn.at(i);
    }
    int i1, i2, i3;//i1はxnの順番、i2はynの順番、i3はcnの順番
    i1 = x - 1;
    i2 = y - 1;
    i3 = 0;
    bool ck1, ck2;
    ck1 = true;;
    ck2 = true;
    for(int i = 0; i < c; i++){//c個のりんごについて交換すべきかを考える
    if(xn.at(i1) >= yn.at(i2) && yn.at(i2) < cn.at(i3) && ck2){//y末尾の方が小さい→y末尾を交換
        yn.at(i2) = cn.at(i3);
        i2--;//交換したので一個手前について検討
        i3++;//交換したので一個後ろについて検討
        if(i2 == -1){
            i2++;
            ck2 = false;
        }
    }
    else if(xn.at(i1) < yn.at(i2) && xn.at(i1) < cn.at(i3) && ck1){
        xn.at(i1) = cn.at(i3);
        i1--;
        i3++;
        if(i1 == -1){
            i1++;
            ck1 = false;
        }
    }
    }
    for(int i = 0; i < x; i++){
        ans += xn.at(i);
    }
    for(int i = 0; i < y; i++){
        ans += yn.at(i);
    }
    solve();
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, flag=0, ans=0;
	vector<int> p, q;

	cin>> n;
	q.resize(n);
	p.resize(n);

	for (int i = 0;i<n;i++) cin >> p[i];
	for (int i = 0;i<n;i++) cin >> q[i];

	for (int i = 0;i < n;i++) {
		if (p[i] < q[i]) {
			flag = -1;
			break;
		}
		if (p[i] > q[i]) {
			flag = 1;
			break;
		}

	}
	//cout << flag << endl;
	if (flag == 0) {
		cout << "0" << endl;
		return 0;
	}

	if (flag == -1) {
		while (1) {
			ans++;
			flag = 1;
			next_permutation(p.begin(), p.end());
			for (int i = 0;i < n;i++) {
				if (p[i] != q[i]) flag = 0;
			}
			if (flag) {
				cout << ans << endl;
				return 0;
			}
		}
	}
	else {
		while (1) {
			ans++;
			flag = 1;
			next_permutation(q.begin(), q.end());
			for (int i = 0;i < n;i++) {
				if (q[i] != p[i]) flag = 0;
			}
			if (flag) {
				cout << ans << endl;
				return 0;
			}
		}

	}


}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int N, i, j, k;
	cin >> N;
	double x[N], y[N], length;
	for (i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	length = 0.0;
	for (i = 0; i < N-1; i++) {
		for (j = i + 1; j < N; j++) {
			length += sqrt(pow((x[i] - x[j]), 2.0) + pow((y[i] - y[j]), 2.0));
		}
	}
	length = length * 2.0 / (double)(N);
	cout << setprecision(15) << length<<endl;
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

p = defaultdict(int)
for d in D:
  p[d] += 1

for t in T:
  if p[t] == 0:
    print("NO")
    exit(0)
  else:
    p[t] -= 1

print("YES")


Measured memory_bytes: 139924
#include <cstdint>
#include <iostream>

int main(void)
{
    uint32_t n, a;

    std::cin >> n;
    std::cin >> a;

    uint32_t mod = n % 500;

    if (mod <= a) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }
    bool flag = true;
    for (auto m : mp)
    {
        if (m.second % 2 != 0)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 7680
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		int[] v = new int[n];
		int[] c = new int[n];
		for(int i = 0; i<n; i++){
			v[i]= sc.nextInt();
		}
		for(int i = 0; i<n; i++){
			c[i]= sc.nextInt();
		}
		for(int i = 0; i<n; i++){
			if(v[i]-c[i]>0){
				ans+=v[i]-c[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, m;
vector<int> a;
vector<pair<int, int>> ans;

int main()
{
    cin>>n;
    REP(i,n) {
        int tmp_a;
        cin>>tmp_a;
        a.push_back(tmp_a);
    }
    SORT(a);
    ll cans = a[0];
    int bunki = lower_bound(a.begin(), a.end(), 0) - a.begin();
    bunki = max(bunki, 1);
    bunki = min(bunki, n-1);
    RFOR(i,n-1,bunki) {
        ans.push_back({cans, a[i]});
        cans = cans - a[i];
    }
    ans.push_back({a[n-1], cans});
    cans = a[n-1] - cans;
    FOR(i,1,bunki) {
        ans.push_back({cans, a[i]});
        cans = cans - a[i];
    }
    cout<<cans<<endl;
    REP(i,n-1)
        cout<<ans[i].first<<" "<<ans[i].second<<endl;

    return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)


int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S[N] = 'X';

  vector<int> counts(N + 1, 0);
  char before = ' ';
  int count = 1;
  int pattern = 0;
  rep0(i, N + 1) {
    if (S[i] != before) {
      if (before != ' ') {
        counts[pattern] = count;
        pattern++;
      }

      count = 1;
      before = S[i];
    } else {
      count++;
    }
  }
  // SHOW(counts);
  // sort(counts.begin(), counts.end(), greater<int>());
  // SHOW(counts);

  ll ans = N - pattern + 2 * K;
  if (ans >= N - 1) ans = N - 1;

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 896
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

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

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	cout << n * (n - 1) / 2 - n / 2 << endl;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if ((n % 2 == 1 && i + j != n) || (n % 2 == 0 && i + j != n + 1))
				cout << i << ' ' << j << endl;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

ll par2(ll l) {
    ll ans = 0;
    while (l % 2 == 0) {
        l /= 2;
        ans++;
    }
    return ans;
}

vector<ll> map_par2(vector<ll> v) {
    int n = v.size();
    vector<ll> u(n);
    rep(i, n) u[i] = par2(v[i]);
    return u;
}

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

    rep(i, n) v[i] /= 2;

    vector<ll> u = map_par2(v);

    if (*max_element(u.begin(), u.end()) != *min_element(u.begin(), u.end())) {
        cout << 0 << endl;
        ret();
    }

    ll p = u.front();

    vector<ll> t(n);
    rep(i, n) t[i] = v[i] / (1ll << p);

    ll k = t.front();
    rep(i, n) {
        k = k / __gcd(k, t[i]) * t[i];
    }

    ll f = m / (1ll << p) / k;
    ll ans = (f + 1) / 2;
    cout << ans << endl;

}

Measured memory_bytes: 5620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
string a,b;
  cin>>a>>b;
  cout<<b<<a;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  std::vector<long long int> vec(2);
  long long int answer;
  std::cin >> vec[0] >> vec[1];
  std::sort(vec.begin(), vec.end());

  for(int i = vec[0]; i > 0; i--){
    if(vec[0] % i == 0 & vec[1] % i == 0){
      vec[0] = vec[0] / i;
      vec[1] = vec[1] / i;
      answer = i * vec[0] * vec[1];
      break;
    }
  }

  std::cout << answer << std::endl;

  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    int maxv,smaxv;
    rep(i,n) cin >> a[i];
    vector<int> b = a;
    sort(b.begin(),b.end());
    maxv = b[n-1];
    smaxv = b[n-2];
    for(int i = 0; i < n; i++){
        if(a[i] == maxv) cout << smaxv << endl;
        else cout << maxv << endl;
    }
}

Measured memory_bytes: 3200
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#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>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, L, q, a[N], R[N][20];

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   cin >> L >> q;
   for (int i = 1; i <= n; i ++) {
      int pos = n;
      int l = i, r = n;
      while (l <= r) {
         int mid = l + r >> 1;
         if (a[mid] - a[i] <= L) l = mid + 1, pos = mid;
         else r = mid - 1;
      }
      R[i][0] = pos; 
   }
   for (int i = n; i >= 1; i --) {
      for (int j = 1; j < 20; j ++) 
         R[i][j] = R[R[i][j - 1]][j - 1];
   }
   while (q --) {
      int l, r;
      cin >> l >> r;
      if (l > r) swap (l, r);
      int pos = l;
      int ans = 0;
      for (int i = 19; i >= 0; i --) {
         if (R[pos][i] < r) {
            pos = R[pos][i];
            ans += (1 << i);
         }
      }
      cout << ans + (pos != r) << endl;
   }
}               
 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 11868
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := readString()
	if strings.Contains(s, "AB") || strings.Contains(s, "BA") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N ;
  int ans =0;
  for(int C=1;C<=N;C+=2){
    int yakusu = 0;
    for(int X = 1;X<=C;X++){
      if(C % X == 0){
        yakusu++;
      }
    }
    if(yakusu == 8){
      ans++;
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256