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

const int INF = 1e9;

int main() {
  int n, m;
  cin>>n>>m;
  vector<pair<int, int> > p;
  p.reserve(m);
  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    p.emplace_back(b, a);
  }
  sort(p.begin(), p.end());

  int ans = 0;
  int t = 0;
  for (auto x: p) {
    if (x.second >= t) {
      ++ans;
      t = x.first;
    }
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 1024
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int N = r.i();
        long[] T = r.ll(N);
        long ans = T[0];
        for(int i = 1; i < N; i++)
            ans = lcm(ans, T[i]);
        println(ans);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }

    static long lcm(long a, long b){
        return a/gcd(a, b)*b;
    }
    static long gcd(long a, long b){
        if(b < a){
            long c = a;
            a = b;
            b = c;
        }
        long r;
        while((r=b%a)>0){
            b = a;
            a = r;
        }          
        return a;
    }

    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }   

        long[] ll(int N) throws IOException{
            long[] ll = new long[N];
            for(int i = 0; i < N; i++) ll[i] = l();            
            return ll;
        }
    }
}

Measured memory_bytes: 22996
n,k = map(int,input().split())
p = [int(x) for x in input().split()]

maxp = sum(p[0:k])
s = maxp
save = 0
pre = p[0]
for i in range(k,n):
    s = s - p[i-k] + p[i]
    if(maxp < s):
        maxp = s
        save = i-k+1

score = 0
for i in range(save,save+k):
    score += (1+p[i])/2 
print(score)
    
    

Measured memory_bytes: 25188
#include <bits/stdc++.h>
using namespace std;
# define ll long long
int n,arr[100005],ans[100005],k;
vector <ll> v={100000000};
int calc(int i)
{
    if(ans[i]!=-1)
        return ans[i];
    if(i==n-1)
        return 0;
    int aa=INT_MAX;
    for(int j=i+1;j<=i+k;j++)
    {
        int x=abs(arr[i]-arr[j]);
        int z2=10000000;
        if(j<n)
        {
            z2=calc(j);
        }
        aa=min(x+z2,aa);
    }
    ans[i]=aa;
    return aa;
 
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    cin>>n>>k;
    //int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    memset(ans,-1,sizeof(ans));
 
    int sum=calc(0);
    cout<<sum;
    //code goes here
	return 0;
}

Measured memory_bytes: 5760
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

#include <set>
void solve() {
  int n;
  cin >> n;
  set<int> S;
  loop(i,1,n+1) {
    int x = i;
    loop(j,1,501) {
      x *= i;
      if (x > n) break;
      S.insert(x);
    }
  }

  auto iter = S.lower_bound(n);
  if (iter == S.end()) iter--;
  else while (*iter > n and iter != S.begin()) iter--;
  cout << *iter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
string S;
const string agct="AGCT";
int main(){
    cin>>S;
    ll ans=0,inx=-1;
    REP(i,S.size()){
        bool flg=false;
        REP(j,4){
            if(S[i]==agct[j]){
                flg=true;
            }
        }
        if(flg){
            ans=max(ans,i-inx);
        }else{
            inx=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  vector<int>dp(n,INT_MAX);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+k;j++){
      if(j<n)
      dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
    
    }}
    cout<<dp[n-1];
  
return 0;}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    string s;cin >> s;
    ll n=s.size();
    ll ans=n*(n+1)/2-n+1;
    vl cnt(26,0);
    rep(i,n){
        cnt[s[i]-'a']++;
    }
    rep(i,26){
        ans-=cnt[i]*(cnt[i]-1)/2;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String args[]) throws IOException {
        FastReader s = new FastReader();
        int a = s.nextInt();
        int b = s.nextInt();
        String z = Integer.toString(a)+Integer.toString(b);
        Integer x = Integer.parseInt(z);
        for(int i=1;i<=317;i++){
            if(i*i == x){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(len(x)):
  x[i] = abs(x[i] - X)
g = x[0]
for i in range(1, N):
  g = fractions.gcd(g, x[i])
  
print(g)

Measured memory_bytes: 16240
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>

using namespace std;

int main() {

  int a = 0;
  int res[2000][2] = {};

  while (true) {
    string s;
    if (!getline(cin, s))
      break;

    if (s == "") {
      a = 1;
      continue;
    }

    int c, d;
    string s2;
    stringstream ss(s);
    getline(ss, s2, ',');
    res[atoi(s2.c_str())][a] += 1;
  }

  for (int i = 0; i < 2000; ++i)
    if ( (res[i][0] != 0) && (res[i][1] != 0) )
      cout << i << " " << res[i][0] + res[i][1] << endl;
}


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

using namespace std;

int main(){
	//~ freopen("input.txt", "r", stdin);
	//~ freopen("output.txt", "w", stdout);
	char s[2];
	scanf("%s", s);
	if (s[0] >= 'A' && s[0] <= 'Z')
		printf("A\n");
	else 
		printf("a\n");
	return 0;
}


Measured memory_bytes: 3660
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = A - (B * 2);
        
        if (C <= 0) {
            System.out.println(0);
        }
        else {
            System.out.println(C);
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
string s;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>s;
  ll cnt =0;
  rep(i,3) if(s[i]=='o') cnt++;
  cout<<700+100*cnt<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
(defvar *days*
  '("SUN" "MON" "TUE" "WED" "THU" "FRI" "SAT"))

(defun solve (s)
  (- 7 (position s *days* :test 'equal)))

#-swank
(let ((s (read-line)))
  (format t "~A~%" (solve s)))


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

set<int> t;
int n;
int a[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(t.find(a[i])!=t.end()){
            cout<<"NO"<<endl;
            return 0;
        }
        t.insert(a[i]);
    }
    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 10368
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int l = s.length();

        for(int i=0; i<l; i+=2){
            System.out.print(s.charAt(i));
        }
        System.out.println();
    }
}

Measured memory_bytes: 29728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <cstdlib>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a;
    cin >> a;

    string str = to_string(a);

    int i;

    if(str.size()==1){
        i = a;
    }else{
        //int i = str.substr(str.size());
        i = stoi(str.substr(str.size()-1,str.size()-1));
    }


    //cout << i << endl;

    if(i == 3){
        cout << "bon";
    }else if(i == 0||i==1||i==6||i==8){
        cout << "pon";
    }else{
        cout << "hon";
    }


    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	char c;
	vector<int> x(N), y(N), d(N);
	map<int, set<P>> mp1, mp2;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> c;
		mp1[x[i]].insert(P(y[i], i));
		mp2[y[i]].insert(P(x[i], i));

		d[i] = c == '>' ? 0 : c == '^' ? 1 : c == '<' ? 2 : 3;
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		auto t1 = mp1;
		auto t2 = mp2;
		int p = i;
		int cnt = 0;
		while (1) {
			t1[x[p]].erase(P(y[p], p));
			t2[y[p]].erase(P(x[p], p));
			cnt++;
			if (d[p] == 3) {
				auto ite = t1[x[p]].lower_bound(P(y[p], 0));
				if (t1[x[p]].empty() || ite == t1[x[p]].end()) {
					break;
				}
				p = ite->second;
			}
			else if (d[p] == 0) {
				auto ite = t2[y[p]].lower_bound(P(x[p], 0));
				if (t2[y[p]].empty() || ite == t2[y[p]].end()) {
					break;
				}
				p = ite->second;
			}
			else if (d[p] == 1) {
				auto ite = t1[x[p]].upper_bound(P(y[p], 1e9));
				if (t1[x[p]].empty() || ite-- == t1[x[p]].begin()) {
					break;
				}
				p = ite->second;
			}
			else {
				auto ite = t2[y[p]].upper_bound(P(x[p], 1e9));
				if (t2[y[p]].empty() || ite-- == t2[y[p]].begin()) {
					break;
				}
				p = ite->second;
			}
		}
		res = max(res, cnt);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4212
#include <cstdio>
#include <cmath>

int main() {
    double r;
    scanf("%lf", &r);

    double area = M_PI * r*r;
    double circle = 2.0 * M_PI * r;

    printf("%.5lf %.5lf\n", area, circle);
    return 0;
}


Measured memory_bytes: 2728
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long
#define mod 1000000007
#define test int t; cin>>t; while(t--)
#define f for(int i=0;i<n;i++)
#define f1 for(int i=1;i<n-1;i++)
#define read(x) ll x; cin>>x;

using namespace std;
int main() {

    int arr[5],s=0;
    for(int i=1;i<=5;i++) {
        cin >>arr[i];
    }
    s=15-arr[1]-arr[2]-arr[3]-arr[4]-arr[5];
    cout<<s;
}

Measured memory_bytes: 3580
import java.io.*
import java.util.*

fun solve(X: Long, Y: Long){
    println(X + Y/2L)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val X = sc.next().toLong()
    val Y = sc.next().toLong()
    solve(X, Y)
}



Measured memory_bytes: 31268
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
X = int(input())
if X <2000 :
    count = X//100
    if X%100 > count*5 :
        print(0)
    else:
        print(1)
else:
    print(1)

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

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

	int Q = 0, ans = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')Q++;
		else Q = 0;

		if (ans < Q) ans = Q;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <climits>
#include <vector>

using namespace std;

int minHugs(const string str) {
    int n = str.size();
    vector<vector<int>> dp(n, vector<int>(n, INT_MAX));

    for (int l = 0; l < n; ++ l) {
        for (int i = 0; i < n; ++ i) {
            if (i + l >= n) break;
            if (l == 0) dp[i][i+l] = 0;
            else if (l == 1) dp[i][i+l] = (str[i] == str[i+l] ? 0 : 1);
            else {
                dp[i][i+l] = min(dp[i][i+l], dp[i+1][i+l-1]+(str[i] == str[i+l] ? 0 : 1));
            }
        }
    }
    return dp[0][n-1];
}

int main() {
    string s; 
    cin>>s;
    cout<<minHugs(s)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    ll x,y;
    cin>>x>>y;
    ll tmp=x;
    ll sum=0;
    while(tmp<=y){
        tmp*=2;
        sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
#define Cannot puts("No"), exit(0);
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 505;
struct Node { int pos, id; } t[MAXN];
int ans[MAXN * MAXN];
int pre[MAXN * MAXN], nxt[MAXN * MAXN];

inline bool cmp(Node x, Node y) { return x.pos < y.pos; }

inline void Put(int pos, int num, int cnt) {
  for (RI i = nxt[0]; i <= pos && i && cnt; i = nxt[i]) {
    ans[i] = num, --cnt;
    nxt[pre[i]] = nxt[i];
    pre[nxt[i]] = pre[i];
  }
  if (cnt) Cannot;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  for (RI i = 1; i <= n; ++i)
    scanf("%d", &t[i].pos), t[i].id = i;
  sort(t + 1, t + 1 + n, cmp);
  for (RI i = 1; i <= n * n; ++i)
    nxt[i - 1] = i, pre[i] = i - 1;
  pre[0] = n * n;
  for (RI i = 1; i <= n; ++i) {
    nxt[pre[t[i].pos]] = nxt[t[i].pos];
    pre[nxt[t[i].pos]] = pre[t[i].pos];
  }
  for (RI i = 1; i <= n; ++i) {
    ans[t[i].pos] = t[i].id;
    Put(t[i].pos, t[i].id, t[i].id - 1);
  }
  int now = nxt[0];
  for (RI i = 1; i <= n; ++i) {
    int res = n - t[i].id;
    while (res) {
      if (now <= t[i].pos) Cannot;
      ans[now] = t[i].id, --res;
      now = nxt[now];
    }
  }
  puts("Yes");
  for (RI i = 1; i <= n * n; ++i)
    printf("%d ", ans[i]);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 4096
# -*- coding: utf-8 -*-

import math

def main():

    K = int(input())

    ans = 0

    for i in range(1, K + 1):
        for j in range(1, K + 1):
            num = math.gcd(i,j)
            for k in range(1, K + 1):
                ans += math.gcd(num, k)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9064
package main

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

func main() {
	run()
}

func run() {
	setSpace()
	N, M, C := readN(), readN(), readN()
	bs := make([]int, M)
	for i := 0; i < M; i++ {
		bs[i] = readN()
	}
	var sum int
	for i := 0; i < N; i++ {
		as := make([]int, M)
		for ii := 0; ii < M; ii++ {
			if ii != 0 {
				as[ii] = as[ii-1]
			}
			as[ii] += readN() * bs[ii]
		}
		as[M-1] += C
		if as[M-1] > 0 {
			sum++
		}
	}
	fmt.Println(sum)
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


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

using namespace std;

const int MAX = 510;

int H, W, h, w;
int ans[MAX];

int main() {
    cin >> H >> W >> h >> w;
    if (H%h == 0 && W%w == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    bool t = (H%h == 0);
    if (t) swap(H, W), swap(h, w);

    ans[0] = H/h+1;
    for (int i = 1; i < h-1; i++) ans[i] = 0;
    ans[h-1] = -ans[0]-1;

    if (t) {
        for (int j = 0; j < W; j++)
            for (int i = 0; i < H; i++)
                cout << ans[i%h] << ((i == H-1) ? "\n":" ");
    } else {
        for (int j = 0; j < H; j++)
            for (int i = 0; i < W; i++)
                cout << ans[j%h] << ((i == W-1) ? "\n":" ");
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int cnt=0,cn=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            //s[i+1]='W';
            cnt++;
        }
    }
    for(int i=0;i<cnt;i++)
    {
        if(s[i]=='W')
        {
            //s[i+1]='W';
            cn++;
        }
    }
    cout<<cn;
    
}

Measured memory_bytes: 3728
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun



int main() {
	
	int s;
	cin >> s;
	int x = 1000 - (s % 1000);
	if (x == 1000) x = 0;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	int n;
	cin>>n;
	map<int,int>mp;
	rep(i,n){
		int a;
		cin>>a;
		mp[a]++;
	}
	int ans=n-mp.size();
	if(ans%2==0)cout<<mp.size()<<endl;
	else cout<<mp.size()-1<<endl;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in, M = in;
    vector<int> L(M), R(M);
    rep( i, M ) {
        L[i] = in;
        R[i] = in + 1;
    }

    sort( all(L), greater<int>() );
    sort( all(R) );

    cout << ( R[0]-L[0]<0 ? 0 : R[0]-L[0] ) << "\n";
}


Measured memory_bytes: 1024
import itertools
n, m, q = map(int, input().split())
Q = []
for i in range(q):
    ai, bi, ci, di = map(int, input().split())
    Q.append([ai,bi,ci,di])

X = list(itertools.combinations_with_replacement(range(1, m + 1), n))

ans = -1
for x in X:

    p = 0
    for q in Q:
        if x[q[1]-1] - x[q[0]-1] == q[2]:
            p += q[3]

    if ans < p:
        ans = p


print(ans)



Measured memory_bytes: 21400
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
// include  long long func(long long)
V a;
ll func(ll terget) {
	ll res = 0LL;
	repi(itr, a) { res += ((*itr)+terget-1) / terget -1; }
	return res;
}
// binarlyscearch
// return ->[0]-, [1]+
vector<pair<long long, long long>> BScearch(long long start, long long stop,
                                            long long terget) {
	vector<pair<long long, long long>> tmp = {make_pair(start, 0LL),
	                                          make_pair(stop, INFLL)};
	pair<long long, long long> mid;
	while (abs(tmp[0].first - tmp[1].first) > 1) {
		mid.first  = tmp[0].first + (tmp[1].first - tmp[0].first) / 2;
		mid.second = func(mid.first);
		if (mid.second > terget) {
			tmp[1] = mid;
		} else {
			tmp[0] = mid;
		}
	}
	return tmp;
}
int main() {
	int n;
	ll k;

	cin >> n >> k;
	a.assign(n, 0LL);
	ll up = 0LL;
	rep(i, n) {
		cin >> a[i];
		chmax(up, a[i]);
	}
	VP ans = BScearch(up, 0LL, k);
	clog << ans[0].F << " " << ans[0].S << endl;
	clog << ans[1].F << " " << ans[1].S << endl;
	cout << ans[0].F << endl;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,W,w,v,V=0;
  cin >> N >> W;
  map<int,int> dp[N+1];
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> w >> v;
    for (auto p : dp[i]) {
      dp[i+1][p.first] = max(dp[i+1][p.first],dp[i][p.first]);
      if (p.first+w <= W) {
        dp[i+1][p.first+w] = max(dp[i][p.first]+v,dp[i+1][p.first+w]);
      }
    }
  }
  for (auto p : dp[N]) {
    V = max(V,p.second);
  }
  cout << V;
}

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

#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()

using namespace std;
///////////////////////////////////////////////////////

int a,b;

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

	cin>>a>>b;

	if(a+b>=10){
		cout<<"error"<<endl;
	}
	else{
		cout<<a+b<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    q, h, s, d = map(int, input().split())
    N = int(input())

    h = min(h, q*2)
    s = min(s, h*2)
    d = min(d, s*2)
    print(d * (N//2) + s * (N%2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62076
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int a, b, c;

        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        out.println( (b-a == c-b)? "YES": "NO");
        
        
        sc.close();
    }
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    
    long long a,b;
    cin>>a>>b;
    
    cout<<a*b<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n; n++;
	vector<int> a(n, 0);
	vector<long long> ans(n);
	for(int i = 1; i < n; i++) cin >> a[i];
	int mx = *max_element(a.begin(), a.end());
	int pt = -1;
	for(int i = 0; i < n; i++){
		if(a[i] == mx){
			pt = i;
			break;
		}
	}
	set<pair<int,int> > in_left;
	map<int, long long> occ;
	for(int i = 0; i < pt; i++) in_left.insert({a[i], -i});
	for(int i = pt; i < n; i++) occ[a[i]]++;
	while(pt){
		int up, to;
		tie(up, to) = *(--in_left.end());
		to *= -1;
		long long has = 0, contr = 0;
		while(true){
			auto it = occ.lower_bound(up);
			if(it == occ.end()) break;
			has += it->second;
			contr += (it->first - up) * it->second;
			occ.erase(it);
		}
		ans[pt] += contr;
		occ[up] += has;
		for(int i = to; i < pt; i++) occ[a[i]]++;
		for(int i = to; i < pt; i++) in_left.erase({a[i], -i});
		pt = to;
	}
	for(int i = 1; i < n; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
vector<int>perm,inv;
void init_perm(){
	int x=1e6+1;perm.resize(x);inv.resize(x);
	perm[0]=1;
	REP(i,x+1)perm[i]=perm[i-1]*i%mod;
	inv[x]=mod_pow(perm[x],mod-2);
	for(int i=x-1;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}

int N,A[200005];
signed main(){
	init_perm();
	cin>>N;
	rep(i,N)cin>>A[i];
	sort(A,A+N);
	int ans=0;
	int div2=mod_pow(2,mod-2);
	rep(i,N){
		int j=(N-i-1)*div2%mod+1;
		ans+=j*A[i]%mod*mod_pow(2,(N-1))%mod;
		ans%=mod;
	}
	cout<<ans*mod_pow(2,N)%mod<<endl;
}


Measured memory_bytes: 17408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  multiset<int> S;
  rep(i, N) {
    int x;
    cin >> x;
    S.insert(x);
  }
  cin >> M;
  rep(i, M) {
    int x;
    cin >> x;
    if (S.find(x) == S.end()) {
      cout << "NO\n";
      return 0;
    }
    S.erase(S.find(x));
  }
  cout << "YES\n";
  return 0;
}


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


int main()
{
	int a, b ;
	cin >> a >> b;
	if (a == b) {
		cout <<"a " << "==" <<" b"<<"\n";

	}
	else if (a < b) {
		cout << "a " << "<" << " b"<<"\n";
	}
	else {
		cout << "a "<< ">" << " b"<<"\n";
	}
    
return	0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;

vvi x(11, vi(101));
int reverse(string &s){
    int n = s.size(), n2 = n/2;
    for (int i=0; i<n2; i++)
        swap(s[i], s[n-1-i]);
    return 0;
}

string dec2bin(int n, bool r=false){
	string s="";
	while (n>0){
		if (n%2==1) s+="1";
		else s+="0";
		n/=2;
	}
	if (s=="") s="0";
	if (!r) reverse(s);
	return s;
}

int main(void){
	int m=pow(2,10);
	for (int i=0; i<10; i++)
		for (int j=0; j<101; j++)
			x[i][j] = 0;

	string s;
	for (int i=1; i<m; i++){
		s = dec2bin(i, true);
		s += string(10-s.size(),'0');

		int n=0, c=0;
		for (int i2=0; i2<s.size(); i2++)
			if (s[i2]=='1'){
				n += i2;
				c++;
			}
		x[c][n]++;		
	}

	while (true){
		int a1,a2;
		cin>>a1>>a2;
		if (a1==0 && a2==0) break;
		cout<<x[a1][a2]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<vector<ll>> dp;
vector<ll> a;

ll dfs(ll l,ll r,bool depth){
    if(l==r){return dp[l][r]=a[l]*(depth?-1:1);}
    if(dp[l][r]!=E){return dp[l][r];}
    if(depth){
        return dp[l][r]=min(dfs(l,r-1,!depth)-a[r],dfs(l+1,r,!depth)-a[l]);
    }
    return dp[l][r]=max(dfs(l,r-1,!depth)+a[r],dfs(l+1,r,!depth)+a[l]);
}


int main(){
    ll n;
    cin>>n;
    a.resize(n);
    for(auto &i:a){cin>>i;}
    dp.resize(n+1,vector<ll>(n+1,E));
    cout<<dfs(0,n-1,false)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 70912
/*
 */
#include <iostream>
#include <algorithm>

using namespace std;

// init
// fe[u
int prime[9692]; // 9,592(100,000 ÈºÌfÌ) + 100(iP ÌÅål)
int primeN;

// input
int iN; // 0 <= N <= 100,000
int iP; // 1 <= P <= 100

// manage
int iM[5050]; // 1 ~ 100 ÜÅÌa

// ú»
void init() {
  int i, j;
  bool isPrime[101198]; // 9692 ÔÚÌf = 101197

  primeN = 0;
  fill(isPrime, isPrime + 101198, true);
  isPrime[0] = isPrime[1] = false;

  for (i = 2; i < 101198; i++) {
    if (isPrime[i]) {
      prime[primeN++] = i;
      for (j = 2; i * j < 101198; j++) {
        isPrime[i * j] = false;
      }
    }
  }
}

// üÍ
bool input() {
  scanf("%d %d", &iN, &iP);
  if (iN == -1 && iP == -1) return false;
  return true;
}

// 
void manage(){
  int i, j, k;
  int cnt = 0;
  //int tmp;

  // iN æèå«¢f©ç 2 ÂðIñÅaðÆé
  for (i = 0; i < primeN; i++) {
    if (prime[i] > iN) break;
  }
  for (j = 0; j < iP; j++) {
    for (k = j; k < iP; k++) {
      iM[cnt++] = prime[i + j] + prime[i + k];
    }
  }

  // ou\[g(æª©çiPÔÜÅ\[g)
  /*
  for (j = 0; j < iP; j++) {
    for (k = cnt - 1; k > j; k--) {
      if (iM[k - 1] > iM[k]) {
        tmp = iM[k];
        iM[k] = iM[k - 1];
        iM[k - 1] = tmp;
      }
    }
  }
  */
  sort(iM, iM + cnt);
}

// oÍ
void output(){
  printf("%d\n", iM[iP - 1]);
}

// mizoSâ¤Ê
int main() {
  init(); // ú»
  while(1) {
    if (!input()) break; // üÍ + I¹»è
    manage(); // 
    output(); // oÍ
  }
  return 0;
}

Measured memory_bytes: 1024
a,b,c=map(int,input().split())

if a==b and a==c and a%2==0:
  print(-1)

else:
  cnt=0
  while a%2==0 and b%2==0 and c%2==0:
    cnt+=1
    i=a
    j=b
    a=(b+c)//2
    b=(i+c)//2
    c=(i+j)//2
  print(cnt)

Measured memory_bytes: 9008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const ll inf = 1e12 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define endl '\n'
ll prime[1000001];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n); 
int main()
{

	flash
	ll n;ll a,b;
	cin >> n;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0) {
			a=i;b=n/i;
		}
	}
	cout << a+b-2;
}
//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n) 
{ 
    return floor(log10(n) + 1); 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    vector<vector<ll>> g(n+1);
    map<p, ll> I{};
    for(ll i = 0; i < n-1; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        g[a].push_back(b);
        g[b].push_back(a);
        I[p(a, b)] = c; I[p(b, a)] = c;
    }
    ll q, k;
    cin >> q >> k;
    vector<p> vp;
    for(ll i = 0; i < q; i++){
        ll a, b;
        cin >> a >> b;
        vp.push_back(p(a, b));
    }
    queue<ll> que;
    vector<ll> dist(n+1, -1);
    dist[k] = 0;
    que.push(k);
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(ll nv : g[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v] + I[p(v, nv)];
            que.push(nv);
        }
    }
    for(ll i = 0; i < vp.size(); i++){
        ll a = vp[i].first, b = vp[i].second;
        cout << dist[a] + dist[b] << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    for (;;n++) {
        if (n / 100 == (n / 10) % 10 && n / 100 == n % 10) {
            cout << n << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    #CODE GOES HERE:
    x,y=map(int,input().split())
    if y%2!=0:print("No")
    else:
        flag=True
        for i in range(x+1):
            if (2*i)+(4*(x-i))==y:
                print("Yes")
                flag=False
                break
        if flag:print("No")
main()

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

int main(){
  int n; cin >> n;
  vector<string> s(n);
  int ans1 = 0, acnt = 0, bcnt = 0, abcnt = 0;
  rep(i, n) cin >> s[i];
  bool ok = false;
  rep(i, n){
    rep(j, s[i].size() - 1){
      if(s[i][j] == 'A' && s[i][j + 1] == 'B') ans1++;
    }
    if(s[i][s[i].size() - 1] == 'A' && s[i][0] == 'B') abcnt++;
    if(s[i][s[i].size() - 1] == 'A' && s[i][0] != 'B') acnt++;
    if(s[i][s[i].size() - 1] != 'A' && s[i][0] == 'B') bcnt++;
  }
  int ans2 = min(acnt, bcnt);
  if(acnt > 0 || bcnt > 0) ans2 += abcnt;
  else ans2 += max(abcnt - 1, 0);
  cout << ans1 + ans2 << endl;
  return 0;
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define dreps(i,cc,n) for(int i=cc;i>(n);--i)
#define llreps(i,cc,n) for(long long i=cc;i<(n);++i)
#define ALL(v) begin(v),end(v)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;


string MOJI(ll N)
{
	string ans = "";
	while (N > 0) {
		--N;                    //「a-z：1-26」を「a-z：0-25」に変換
		ans += (N % 26) + 'a';  //【'a'+[0-25]】の文字を末尾に追加
		N /= 26;                //
	}
	reverse(ALL(ans));
	return ans;
}
int main()
{
	ll n;
	cin >> n;
	cout << MOJI(n) << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int sum = 0;
	while(!s.empty()) {
		s.pop_back();
		bool ok = true;
		for(int i = 0; i < s.size() / 2; i++) {
			if(s[i] != s[s.size() / 2 + i] || s.size() % 2 == 1)  {
				ok = false;
				break;
			}
		}
		if(ok) {
			sum = s.size();
			break;
		}
	}
	cout << sum << endl;
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
#define ull unsigned long long
#define getbit(x,i) (x>>i)&1

void solve(){
    ll n;cin>>n;
    vector<ll> a(n);
    ll x=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        x^=a[i];
    }
    for(ll i=0;i<n;i++) cout<<(x^a[i])<<' ';
    cout<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        // cout<<"Case #"<<cas<<": ";
        solve();
    }
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s,t;
  cin >> s >> t;
  int i=0;
  for(int j=0;j<t.length();j++){
    if(s[i]==t[j]){
      i+=2;
      if(i>=s.length()){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  i=1;
  for(int j=0;j<t.length();j++){
    if(s[i]==t[j]){
      i+=2;
      if(i>=s.length()){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  if(s.length()<=1){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,a,b,c,d;
int main(void){
    cin>>a>>b>>c>>d>>n;
    ll one=min({a*4,b*2,c});
    ll two=min({a*8,b*4,c*2,d});
    cout<<n/2*two+n%2*one;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[10][10];
ll b[100];
ll ans[20][20];

bool check(int m, int k) {
	set<ll> setik;
	for (int mask = 0; mask < (1 << m); mask++) {
		int cnt = 0;
		ll sum = 0;
		for (int i = 0; i < m; i++) {
			if ((mask >> i) & 1) {
				cnt++;
				sum += a[k][i];
			}
		}
		if (k == 0) {
			if (cnt == 2) {
				if (setik.count(sum)) return false;
				setik.insert(sum);
			}
		} else {
			if (cnt <= k) {
				if (setik.count(sum)) return false;
				setik.insert(sum);
			}
		}
	}
	return true;
}

void checkAns(int n) {
	int p[20];
	set<ll> setik;
	for (int i = 0; i < n; i++) {
		p[i] = i;
	}
	ll mx = 0;
	do {
		if (p[0] > p[n - 1]) continue;
		ll sum = 0;
		for (int i = 1; i < n; i++)
			sum += ans[p[i - 1]][p[i]];
		if (setik.count(sum)) throw;
		setik.insert(sum);
		mx = max(mx, sum);
	} while(next_permutation(p, p + n));
	cerr << (double)mx / 1e11 << endl;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	for (int k = 0; k < 6; k++) {
		a[k][0] = 1;
		for (int i = 1; i < 10; i++) {
			for (ll x = a[k][i - 1] + 1;; x++) {
				a[k][i] = x;
				if (check(i + 1, k)) break;
			}
		}
		/*
		for (int i = 0; i < 10; i++)
			printf("%lld\t", a[k][i]);
		printf("\n");
		*/
	}
/*	
	for (int i = 0; i <= 45; i++) {
		ll sum = 0;
		for (int j = max(0, i - 9); j < i; j++)
			sum += b[j];
		b[i] = sum + 1;
	}
	cerr << (double)b[45] / 1e11 << endl;
*/
	ll res = 1;
	for (int i = 0; i < 9; i++) {
		int k = 2;
		if (i == 5) k = 0;
		b[i] = (i > 0 ? a[k][i - 1] : 0) + a[k][i] + 1;
		res *= b[i];
	}
/*
	cerr << (double)res / 1e11 << endl;

	for (int i = 0; i < 9; i++)
		cerr << b[i] << " ";
	cerr << endl;
*/

	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int k = 2;
		if (i == 6) k = 0;
		ll p = 1;
		for (int j = 0; j < i - 1; j++)
			p *= b[j];
		for (int j = 0; j < i; j++)
			ans[i][j] = ans[j][i] = a[k][j] * p;
	}
//	checkAns(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			printf("%lld ", ans[i][j]);
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 256
h,w,k=gets.split.map(&:to_i)
C=Array.new(h).map{Array.new(w,0)}
for i in 0..h-1
  C[i]=gets.chomp.split("").map(&:chomp)
end
c=0
(1<<h).times{|v|
(1<<w).times{|w|
b=0
h.times{|i|
w.times{|j|
b+=1 if C[i][j]=="#" && (v[i]==1 && w[j]==1)
}
}
c+=1 if b==k
}
}
p c


Measured memory_bytes: 14248
package main

import (
  "fmt"
  "sort"
)

func sumInt(a ...int) int {s := 0; for _, v := range a {s += v}; return s}

func main() {
  var n, m int 
  fmt.Scan(&n, &m)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }
  sort.Ints(a)
  s := sumInt(a...)
  ans := "No"
  if a[n-m] * 4*m >= s {
    ans = "Yes"
  }
  fmt.Println(ans)
  

}

Measured memory_bytes: 512
// In the name of God

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

pair<ll,int> p[maxn];
map<ll,vector<int> >mp;
int par[maxn],SZ[maxn];
vector<int>v[maxn];

pair<ll,int> dfs(int u,int par=-1){
    ll A=0;
    int B=1;
    for(int y:v[u]){
	if(y!=par){
	    pair<ll,int>p=dfs(y,u);
	    B+=p.S;
	    A+=p.F+p.S;
	}
    }
    return {A,B};
}

int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
	cin>>p[i].F;
	p[i].S=i;
    }
    sort(p+1,p+n+1);
    for(int i=n;i>=1;i--){
	SZ[p[i].S]=1;
	if(mp.count(p[i].F)){
	    for(int id:mp[p[i].F]){
		par[id]=p[i].S;
		SZ[p[i].S]+=SZ[id];
	    }
	    mp.erase(p[i].F);
	}
	mp[p[i].F+2*SZ[p[i].S]-n].PB(p[i].S);
    }
    for(int i=1;i<=n;i++){
	if(par[i]==0 && i!=p[1].S){
	    return cout<<-1<<endl,0;
	}
	else if(par[i]!=0){
	    v[par[i]].PB(i);
	}
    }
    if(dfs(p[1].S).F!=p[1].F){
	return cout<<-1<<endl,0;
    }
    for(int i=1;i<=n;i++){
	if(i==p[1].S)continue;
	cout<<i<<" "<<par[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 12416
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    string s, t; cin >> s >> t;
    cout << t + s << endl;
    return 0;
}

Measured memory_bytes: 256