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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, long long C, std::vector<std::string> s){
    vector<char> ans;
    for(int i = 0;i < N;i++){
        if(s[i] == "AB"){
            if(A == 0 && B == 0){
                cout<<"No"<<endl;
                return;
            }
            if(A > B){
                A--;
                B++;
                ans.push_back('B');
            }else if(A == B && i != N - 1){
                if(s[i + 1] == "BC" && C == 0 && B == 1){
                    A--;
                    B++;
                    ans.push_back('B');
                }else{
                    A++;
                    B--;
                    ans.push_back('A');
                }
            }
            else{
                A++;
                B--;
                ans.push_back('A');
            }
        }
        if(s[i] == "BC"){
            if(B == 0 && C == 0){
                cout<<"No"<<endl;
                return;
            }
            if(C > B){
                C--;
                B++;
                ans.push_back('B');
            }else if(C == B && i != N - 1){
                if(s[i + 1] == "AB" && A == 0 && B == 1){
                    C--;
                    B++;
                    ans.push_back('B');
                }else{
                    C++;
                    B--;
                    ans.push_back('C');
                }
            }else{
                C++;
                B--;
                ans.push_back('C');
            }
        }
        if(s[i] == "AC"){
            if(A == 0 && C == 0){
                cout<<"No"<<endl;
                return;
            }
            if(C > A){
                C--;
                A++;
                ans.push_back('A');
            }else if(C == A && i != N - 1){
                if(s[i + 1] == "AB" && B == 0 && A == 1){
                    C--;
                    A++;
                    ans.push_back('A');
                }else{
                    C++;
                    A--;
                    ans.push_back('C');
                }
            }else{
                C++;
                A--;
                ans.push_back('C');
            }
        }
    }
    cout<<"Yes"<<endl;
    for(auto a : ans)cout<<a<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    solve(N, A, B, C, std::move(s));
    return 0;
}


Measured memory_bytes: 6804
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, a: "List[int]"):
    n2 = sum(1 for ai in a if ai % 4 == 0)
    n0 = sum(1 for ai in a if ai % 2 == 1)
    ans = NO
    if n2 + 1 == n0 and n2 + n0 == N:
        ans = YES
    elif n2 >= n0:
        ans = YES
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15140
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    imfor(i, s.length()) {
        if (i == s.length() - 8) {
            break;
        }
        else {
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int k = Integer.parseInt(temp[1]);

		String[] temp2 = scanner.nextLine().split(" ");
		int[] 	 list  = new int[n];

		for(int i = 0; i < n; i++) {
			list[i] = Integer.parseInt(temp2[i]);
		}


		int[] dp = new int[n+1];

		Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n && j <= i + k; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(list[j] - list[i]));
            }
        }

        System.out.println(dp[n - 1]);


	}

}


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

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

#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define ferrari ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, cnt;
double sum, a[150];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)	{
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++)
		if (a[i] >= sum / (4 * m))
			cnt++;
	cout << (cnt >= m ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
#define fi first
#define se second


	
int main(){
  ll n,x; cin>>n;
  vector<ll>v;
  for(ll i=0;i<n;i++){
      cin>>x;
      v.pb(x);
  }
  sort(v.begin(),v.end());
  ll last=v[n-1]+1;
  ll dp[last];
  for(ll i=0;i<last;i++) dp[i]=true;
  
 ll i=0,now=0;
 while(i<n){
     if(now!=v[i]){
         now=v[i];
         ll bound=v[n-1]/now;
         for(ll k=2;k<=bound;k++){
             dp[now*k]=false;
         }
     }
     else{
         dp[now]=false;
     }
     i++;
 }
 ll res=0;
 for(ll i=0;i<last;i++){
     if(dp[i] && binary_search(v.begin(),v.end(),i))
     res++;
 }
 cout<<res;
}

  

Measured memory_bytes: 12644
import sys
input=sys.stdin.readline

n=int(input())
a,b,c=map(int,input().split())
for i in range(n-1):
    a1, b1, c1 = map(int, input().split())
    a,b,c=a1+max(b,c),b1+max(a,c),c1+max(a,b)
print(max(a,b,c))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  int ans = INF;

  rep(i, 0, N) {
    int x = v[i];
    dump(x);
    vector<int> a, b;
    rep(j, 0, N) {
      if (v[j] < x) {
        sort(all(a));
        rep(k, 0, (int)a.size() - K + 1) { b.push_back(a[k]); }
        a.clear();
      } else {
        a.push_back(v[j]);
      }
    }
    sort(all(a));
    rep(k, 0, (int)a.size() - K + 1) { b.push_back(a[k]); }
    a.clear();

    if (b.size() < Q)
      continue;
    sort(all(b));
    dump(b);
    chmin(ans, b[Q - 1] - x);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
a = N.times.map { gets.chomp }
b = M.times.map { gets.chomp }

d = N - M + 1
d.times do |i|
  d.times do |j|
    if M.times.all?{ |m| a[m+i][j,M] == b[m] }
      puts "Yes"
      exit
    end
  end
end
puts "No"


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string o, e, ans="";
	cin >> o >> e;
	int total = o.size() + e.size();
	int p = 0;
	REP(i, 0, total){
		if(i % 2 == 0) ans+= o[p];
		else{
			ans += e[p];
			++p;
		}
	}
	cout << ans;

}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && c == a) puts("No");
    else if (a != b && b != c && c != a) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	std::string s;
	std::cin >> s;
	if (s == "ABC") std::cout << "ARC" << std::endl;
	else std::cout << "ABC" << std::endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int digitsum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> p(N, vector<int>(3));
    for (int i = 0; i < N; i++) {
        cin >> p.at(i).at(0) >> p.at(i).at(1) >> p.at(i).at(2);
    }
    
    vector<vector<bool>> squares(W, vector<bool>(H, true));
    
    for (int i = 0; i < N; i++) {
        if (p.at(i).at(2) == 1) {
            for (int j = 0; j < p.at(i).at(0); j++) {
                for (int k = 0; k < H; k++) {
                    squares.at(j).at(k) = false;
                }
            }
        } else if (p.at(i).at(2) == 2) {
            for (int j = p.at(i).at(0); j < W; j++) {
                for (int k = 0; k < H; k++) {
                    squares.at(j).at(k) = false;
                }
            }
        } else if (p.at(i).at(2) == 3) {
            for (int j = 0; j < W; j++) {
                for (int k = 0; k < p.at(i).at(1); k++) {
                    squares.at(j).at(k) = false;
                }
            }
        } else if (p.at(i).at(2) == 4) {
            for (int j = 0; j < W; j++) {
                for (int k = p.at(i).at(1); k < H; k++) {
                    squares.at(j).at(k) = false;
                }
            }
        }
    }
    
    int cnt = 0;
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            if (squares.at(i).at(j)) cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n,largest,high;
	long long int ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>high;
		if(largest>high)ans+=largest-high;
		if(high>largest)largest=high;
	}
	cout<<ans<<endl;
	return 0;
} 

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

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

typedef long long ll;

ll add(ll x, ll y){
	return (x + y) % MOD;
}

ll mul(ll x, ll y){
	return (x * y) % MOD;
}

ll fac[N], inv[N];

ll mod_pow(ll x, ll p){
	ll res = 1;
	while(p){
		if(p&1)res = mul(res, x);
		x = mul(x,x);
		p/=2;
	}
	return res;
}

ll c(ll n, ll k){
	return mul(mul(fac[n], inv[k]), inv[n-k]);
}

int main(){
	fac[0] = 1;
	inv[0] = 1;
	for(int i = 1;i < N; ++i){
		fac[i] = mul(i, fac[i-1]);
		inv[i] = mod_pow(fac[i], MOD - 2);
	}
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	cin >> n >> m;
	vector<int> cnts;
	for(int i = 2; i * i <= m; ++i){
		if(m % i == 0){
			int cnt = 0;
			while(m % i == 0){
				++cnt;
				m/=i;
			}
			cnts.push_back(cnt);
		}
	}
	if(m != 1)cnts.push_back(1); // remember edges!
	ll ans = 1;
	for(int b: cnts){
		ans = mul(ans, c(n + b - 1, n - 1));	
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n, tot, cnt[1000001], k, x;
vector< pair < int , int > > v;
#define pb push_back
#define mk make_pair
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) 
	{
		scanf("%d", &x);
		cnt[x]++;
	}
	for(int i= 1; i <=200000; i++) v.pb(mk(cnt[i], i));
	sort(v.rbegin(), v.rend());
	for (int i = 0; i < k; i++)
	{
		tot+= v[i].first;
	}
	printf("%d\n", n-tot);
	
}

Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  int count=0;
  double all=0;

  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i];
  }
double a,b,c,d;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      count++;
      a=x[i]-x[j];
      b=y[i]-y[j];
      c=pow(a,2);
      d=pow(b,2);
      all +=sqrt(c+d);
    }
  }
  cout << fixed <<all/count*(N-1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    int sa = n;
    cout<<pow(sa,3)<<endl;
    return 0;
}

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

using namespace std;

priority_queue<int, vector<int>, greater<int> > h;
int N, K, A[200010], B[200010];
bool flag;

int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  while (K-- && !flag) {
    flag = 1;
    h = priority_queue<int, vector<int>, greater<int> >();
    for (int i = 1; i <= N; ++i) {
      h.push(A[i] + i);
      while (h.top() - i < 0) h.pop();
      B[i] = h.size();
    }
    h = priority_queue<int, vector<int>, greater<int> >();
    for (int i = N; i; --i) {
      h.push(A[i] - i);
      while (h.top() + i < 0) h.pop();
      A[i] = B[i] + h.size() - 1;
      if (A[i] != N) flag = 0;
    }
  }
  for (int i = 1; i <= N; ++i) printf("%d ", A[i]);
  return 0;
}

Measured memory_bytes: 6712
#include <stdio.h>

#define MAX 100

int n, a[MAX], cnt;

void bubbleSort()
{
	int i, tmp, flag;
	 
	flag = 1;
	cnt = 0;
	while (flag) {
		flag = 0;
		for (i = n - 1; i >= 1; i--) {
			if (a[i] < a[i - 1]) {
				tmp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = tmp;
				flag = 1;
				cnt++;
			}
		}
	}
}

int main()
{
	int i;
	
	scanf("%d",&n);
	
	for (i = 0; i < n; i++) {
		 scanf ("%d",&a[i]);
	}
	bubbleSort();
	
	
	
	for (i = 0; i < n; i++) {
		if (i > 0) {
			printf(" ");
			}
		printf("%d",a[i]);
	}
	printf("\n");
	
	printf("%d\n",cnt);
return 0;
}


Measured memory_bytes: 2120
N=int(input())

#       完全グラフ
#    1     14     -4
#    2     13     -3
#    3     12     -2
#    4     11     -1
#    5     10
#
#       完全グラフ
#    1     20     -6
#    2     19     -5
#    3     18     -4
#    4     17     -3
#    5     16     -2
#    6     15     -1

ans=[]
for i in range(1,N):
    for j in range(i+1,N+1):
        ans.append((i,j))
if N%2==0:
    for i in range(1,N//2+1):
        ans.remove((i,N+1-i))
else:
    for i in range(1,N//2+1):
        ans.remove((i,N-i))
print(len(ans))
for a in ans:
    print(a[0],a[1])


Measured memory_bytes: 43376
import collections

n = int(input())
v = list(map(int, input().split()))
even = []
odd = []
for i in range(0, n, 2):
    odd.append(v[i])
for i in range(1, n, 2):
    even.append(v[i])
odd_counter = collections.Counter(odd)
even_counter = collections.Counter(even)

odd_counter_sorted = sorted(odd_counter.items(),
                            key=lambda x: x[1],
                            reverse=True)
even_counter_sorted = sorted(even_counter.items(),
                             key=lambda x: x[1],
                             reverse=True)
if odd_counter_sorted[0][0] != even_counter_sorted[0][0]:
    print(
        len(odd) - odd_counter_sorted[0][1] + len(even) -
        even_counter_sorted[0][1])
else:
    ans = float("inf")
    if len(odd_counter_sorted) > 1:
        a = len(odd) - odd_counter_sorted[1][1] + len(
            even) - even_counter_sorted[0][1]
    else:
        a = len(odd) + len(even) - even_counter_sorted[0][1]

    if len(even_counter_sorted) > 1:
        b = len(odd) - odd_counter_sorted[0][1] + len(
            even) - even_counter_sorted[1][1]
    else:
        b = len(odd) - odd_counter_sorted[0][1] + len(even)
    print(min(a, b))


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

int main()
{

	int N;
	int A[201];
	int ans=0;
	bool check=true;
	int count=0;
	cin >> N;
	for (int i = 0; i < N; i++) cin>>A[i];

	while (check==true) {
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 0) {
				count++;
				A[i] /= 2;
			}
			else {
				check = false;
					break;
			}
			if (count == N) {
				ans++;
				count = 0;
			}
		}
	}

	cout << ans << endl;
		




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  a+=b;
  c+=d;
  if(a>c) cout << "Left" << endl;
  else if(a==c) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

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

int main(){
        int a, b;
        cin >> a >> b;
        if(a > b) cout << "a > b" << endl;
        if(a == b) cout << "a == b" << endl;
        if(a < b) cout << "a < b" << endl;
        return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int dp[3002][3002];
int main(){
    string s1,s2;
    cin>>s1>>s2;
    int p1=s1.size(),p2=s2.size();
    rep(i,p1){
        rep(j,p2){
            if(s1[i]==s2[j]) dp[i+1][j+1]=dp[i][j]+1;
            else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    string ans;
    int cur=dp[p1][p2];
    cerr<<cur<<endl;
    while(1){
        if(p1>0&&dp[p1-1][p2]==cur) --p1;
        else if(p2>0&&dp[p1][p2-1]==cur) --p2;
        else{
            ans+=s1[p1-1];
            --p1;--p2;
            --cur;
            
        }
        if(cur==0) break;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	auto w = vector<int>(n);
	for(auto&& ww : w) cin >> ww;
	auto s = vector<int>(n);
	s[0] = w[0];
	for(auto i = 1; i < n; ++i){
		s[i] = s[i - 1] + w[i];
	}
	int ans = 100000;
	for(auto i = 1; i < n; ++i){
		ans = min(ans, abs(s[n - 1] - s[i] * 2));
	}
	cout << ans << endl;
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

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

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll n, m, l;

int main(){
	cin >> n >> m >> l;
	if(l-1<=n+m){
		cout << m+l << endl;
	}else{
		cout << n + 2*m + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import qualified Data.List as L
import qualified Data.Map as M
import Data.Maybe
import qualified Data.Set as S
import qualified Data.Tuple as T

addToSet :: (Num a, Ord a) => S.Set (a, Int) -> [(Int, a)] -> S.Set (a, Int)
addToSet set xs = L.foldl' (\ acc x -> S.insert (T.swap x) acc) set xs


addToMap :: Ord k => M.Map k a -> [(k, a)] -> M.Map k a
addToMap m xs = L.foldl' (\ acc (x, d) -> M.insert x d acc) m xs


dijkstra :: (Num a, Ord a) => M.Map Int [(Int, a)] -> Int -> M.Map Int a
dijkstra graph source = dijkstra' graph (S.singleton (0, source))
                        (M.singleton source 0)


dijkstra' :: (Ord t, Num t) => M.Map Int [(Int, t)]     -- ^ graph structure
          -> S.Set (t, Int)                             -- ^ priority queue
          -> M.Map Int t -> M.Map Int t                 -- ^ result
dijkstra' graph pq res
    | S.null pq = res
    | otherwise = dijkstra' graph (addToSet pq' info) (addToMap res info)
    where
      fwd = M.findWithDefault
      ((dis, node), pq') = S.deleteFindMin pq
      nodes = fwd [] node graph
      update = filter (\ (x, e) -> (fwd (-1) x res) == (-1) ||
                                   dis + e < (fwd (-1) x res)) nodes
      info = map (\ (x, e) -> (x, dis + e)) update


buildGraph :: Ord t => [(t, t1, t2)] -> M.Map t [(t1, t2)]
buildGraph edges =
    let g = L.groupBy (\ (x, _, _) (y, _, _) -> x == y) edges
    in M.fromList (map (\ x -> (f1 $ head x, map (\ (_, y, z) -> (y, z)) x)) g)

readInt' :: BS.ByteString -> Int
readInt' = fst . fromJust . BS.readInt

f1 :: (t, t1, t2) -> t
f1 (x, _, _) = x

f3 :: (t, t1, t2) -> t2
f3 (_, _, x) = x

main :: IO ()
main = do
  contents <- BS.lines <$> BS.getContents
  let edges = map (\ [x, y, z] -> (x, y, z))
              (map (\ x -> map readInt' (BS.words x)) contents)
      res = dijkstra (buildGraph $ L.sort $ tail edges) (f3 $ head edges)
      n = f1 $ head edges
  forM_ [0..(n - 1)] $ \i -> do
         if M.member i res
         then print (M.findWithDefault (-1) i res)
         else putStrLn "INF"

Measured memory_bytes: 256872
#include <iostream>
#include <queue>
using namespace std;
typedef pair<string, int> P;

int main(){
  int n, q; cin >> n >> q;
  queue<P> que;
  for(int i=0; i<n; i++){
    string name;
    int t;
    cin >> name >> t;
    que.push(P(name, t));
  }
  int now = 0;
  while(!que.empty()){
    P task = que.front(); que.pop();
    if(task.second <= q){
      now += task.second;
      cout << task.first << " " << now << endl;
    }
    else{
      now += q;
      que.push(P(task.first, task.second - q));
    }
  }
}


Measured memory_bytes: 6352
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, X, Y, x, y;

  std::cin >> N >> M >> X >> Y;

  for (int i = 0; i < N; i ++) {
    std::cin >> x;

    X = std::max(x, X);
  }

  for (int i = 0; i < M; i ++) {
    std::cin >> y;

    Y = std::min(y, Y);
  }

  std::cout << (X >= Y ? "War" : "No War") << std::endl;

  return 0;
}


Measured memory_bytes: 256
H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

AM = 0
for i in range(N):
    AM = max(AM,magic[i][0])
#print(AM)


dp = [INF for i in range(H+AM+1)]
dp[0] = 0

for i in range(1,H+AM+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
for i in range(H,H+AM+1):
    ans = min(ans,dp[i])
print(ans)



Measured memory_bytes: 42988
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int calc(int i)
{
	if (i <= 1)
		return 1;
	else
		return i * calc(i - 1);
}

int main()
{
	long long n, ans = 0,a=0,b=0;
	cin >> n;
	vector<long long> p(n),q(n);
	vector<bool> checkP(n, false), checkQ(n,false);
	for (long long i = 0; i < p.size(); i++)
		cin >> p[i];

	for (long long i = 0; i < q.size(); i++)
		cin >> q[i];

	for (long long i = 0; i < n-1; i++)
	{
		long long countP = 0,countQ=0;
		for (long long j = 0; j < p[i]; j++)
		{
			if (checkP[j])
				countP++;
		}
		for (long long j = 0; j < q[i]; j++)
		{
			if (checkQ[j])
				countQ++;
		}
		checkP[p[i]-1] = true;
		checkQ[q[i]-1] = true;
		a += (p[i] - countP) * calc(n - 1 - i);
		b += (q[i] - countQ) * calc(n - 1 - i);
	}

	ans = abs(a - b);

	cout << ans << endl;
}

Measured memory_bytes: 768
def minkowski(n, x, y, p):
    D = 0
    for i in range(n):
        D += abs(x[i] - y[i])**p

    return(D**(1/p))

def chebyshev(n, x, y):
    D = []
    for i in range(n):
        D.append(abs(x[i] - y[i]))

    return(max(D))

n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

print(minkowski(n, x, y, 1))
print(minkowski(n, x, y, 2))
print(minkowski(n, x, y, 3))

print(chebyshev(n, x, y))

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int main()
{
	ios::sync_with_stdio(false);

	int t;
	cin >> t;
	while (t--)
	{
		int x, d;
		cin >> x >> d;
		cout << (x - 1) * 127 + (d ^ ((x % 2 == 0) * 127)) << "\n";
	}

	return 0;
}

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

int main(){
  string s;
  int n;
  cin>>n>>s;
  int ans=0,cnt=0;
  for (int i = 0; i < n; i++)
  {
    /* code */
    if (s[i]=='I')
    {
      /* code */
      cnt++;
    }
    else
    {
      cnt--;
    }
    ans=max(ans,cnt);
    
    
  }
  cout<<ans<<endl;
  
  }

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] in  = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    int n = in[0];
    int m = in[1];
    int c = in[2];
    int[] b = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    int r = 0;
    for (int i = 0; i < n; i++) {
      int[] a = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
      int sum = 0;
      for (int j = 0; j < m; j++) {
        sum += a[j] * b[j];
      }
      if (sum + c > 0) {
        ++r;
      }
    }
    System.out.println(r);
    sc.close();
  }
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string S, T; cin >> S >> T;
    rep(i, N) cout << S[i] << T[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
int compare(const void *p,const void *q){
	return *(int*)p - *(int*)q;
}
int main(){
	int n,i,j,temp,ba,bb;
	scanf("%d",&n);
	int a[n],b[n];
	for (i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	for(i = 0;i<n;i++){
		b[i] = a[i];
	}
	qsort(b,n,sizeof(int),compare);
	ba = b[n/2-1];
	bb = b[n/2];
	for(i = 0;i<n;i++){
		if(a[i] <= ba) printf("%d\n",bb);
		else printf("%d\n",ba );
	}
}

Measured memory_bytes: 3692
import java.util.*;
public class Main {
	static int henkan(String n){
		return Integer.decode("0x"+n);
	}
	static double dk(String n,String k){
		k=k.substring(1);
		int r = henkan(k.substring(0,2));
		int g = henkan(k.substring(2,4));
		int b = henkan(k.substring(4, 6));
		n=n.substring(1);
		int r2 = henkan(n.substring(0,2));
		int g2 = henkan(n.substring(2,4));
		int b2 = henkan(n.substring(4, 6));
		double result = ((r-r2)*(r-r2)+(g-g2)*(g-g2)+(b-b2)*(b-b2));
		return Math.sqrt(result);
	}
	static String doIt(String n){
		double min = dk(n,hyou[0]);
		int memo=0;
		for(int i=1;i<hyou.length;i++){
			double test = dk(n,hyou[i]);
			if(test<min){
				min=test;
				memo=i;
			}
		}
		return hyou2[memo];
	}
	static String hyou[] = {"#000000","#0000ff","#00ff00","#00ffff","#ff0000","#ff00ff","#ffff00","#ffffff"};
	static String hyou2[] ={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
	
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			String n = in.next();
			if(n.equals("0"))break;
			System.out.println(doIt(n));
		}
	}
}

Measured memory_bytes: 34296
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int A, B, C; std::cin >> A >> B >> C;
  if (A + B >= C) {
    std::cout << B + C << std::endl;
  } else {
    std::cout << 2*B + A + 1 << std::endl;
  }
}


Measured memory_bytes: 256
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	cnt := make([]int, 1e6+5)
	for i := 0; i < n; i++ {
		x := a[i]
		if cnt[x] != 0 {
			cnt[x] = 2
			continue
		}
		for j := x; j < len(cnt); j += x {
			cnt[j]++
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if cnt[a[i]] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 13136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		char ch[];
		
		int n, res;
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.valueOf(string);
			
			int map[][] = new int[n][n];
			int sum[][] = new int[n + 1][n + 1];
			ch = reader.readLine().toCharArray();
			for(int i = 0; i < n; i++){
				map[0][i] = (ch[i] == '.' ? 1 : 0);
				
				if(i > 0){
					sum[1][i + 1] = sum[1][i] + map[0][i];
				}else{
					sum[1][i + 1] = map[0][i];
				}
			}
			for(int i = 1; i < n; i++){
				ch = reader.readLine().toCharArray();
				for(int j = 0; j < n; j++){
					map[i][j] = (ch[j] == '.' ? 1 : 0) + map[i - 1][j];
					
					if(j > 0){
						sum[i + 1][j + 1] = sum[i + 1][j] + map[i][j];
					}else{
						sum[i + 1][1] = map[i][0];
					}
				}
			}
			
			if(sum[n][n] == 0){
				System.out.println(0);
				continue;
			}
			res = 1;
			x : for(int w = n + 1; w > 0; w--){
				for(int i = n; i > 0; i--){
					if(i - w < 0) break;
					for(int j = n; j > 0; j--){
						if(j - w < 0) break;
						
						if(sum[i][j] - sum[i - w][j] - sum[i][j - w] + sum[i - w][j - w] == w * w){
							res = w;
							break x;
						}
					}
				}
			}
			System.out.println(res);
		}
		reader.close();
	}
}

Measured memory_bytes: 66820
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    for(int a=1; a<=n; ++a){
        int ans = 0;
        for(int x=1; x*x<=a; ++x){
            for(int y=1; y*y<=a; ++y){
                int b = x + y;
                int c = x * x + y * y + x * y - a;
                int z = (int)((-b + sqrt(b * b - 4.0 * c)) / 2.0 + 0.5);
                if(z >= 1 && x * x + y * y + z * z + x * y + y * z + z * x == a)
                    ++ ans;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
import numpy as np

A, B  = map(int, input().split())
grid = []
for h in range(100):
    str = "#"*50 + "."*50
    grid.append(list(str))
cntA = 0
while cntA < A - 1:
    w = cntA % 25
    h = cntA // 25
    grid[2*h][2*w] = "."
    cntA += 1
cntB = 0
while cntB < B - 1:
    w = cntB % 25 + 25
    h = cntB // 25  
    grid[2*h][2*w+1] = "#"
    cntB += 1

print(100,100)
for s in grid:
    print("".join(s))

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

using namespace std;

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

  int a[210][3];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  vector<int> ans(n, 0);
  for (int i = 0; i < 3; i++) {
    map<int, int> mp;
    for (int j = 0; j < n; j++) {
      mp[a[j][i]]++;
    }
    for (int j = 0; j < n; j++) {
      ans[j] += (mp[a[j][i]] == 1) * a[j][i];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S;
  cin>>S;
  cout<<(S[0]-'0')+(S[1]-'0')+(S[2]-'0')+(S[3]-'0')+(S[4]-'0')+(S[5]-'0');
return 0;}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define N 10000010
#define M 110
int p[N],isp[N],s[N],a[M],b[M],vis[M*2],mat[M*2];
vector <int> E[M];
bool dfs(int x){
	for (auto &i:E[x]){
		if (!vis[i]){
			vis[i]=1;
			if (!mat[i] || dfs(mat[i])){
				mat[i]=x;return 1;
			}
		}
	}
	return 0;
}
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
int main(){
	int tot=0,cnt1=0,cnt2=0,ans=0;
	for (int i=2;i<N;++i){
		if (!isp[i]) p[++tot]=i;
		for (int j=1;j<=tot && i*p[j]<N;++j){
			isp[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
	int n=read();isp[1]=1;
	for (int i=1;i<=n;++i) s[read()]=1;
	for (int i=1;i<N;++i){
		if (s[i]!=s[i-1]){
			if (i&1) a[++cnt1]=i;
			else b[++cnt2]=i;
		}
	}
	for (int i=1;i<=cnt1;++i){
		for (int j=1;j<=cnt2;++j){
			if (!isp[abs(a[i]-b[j])]) E[i].push_back(j);
		}
	}
	for (int i=1;i<=cnt1;++i){
		memset(vis,0,sizeof(vis));ans+=dfs(i);
	}
	cout<<ans+(cnt1-ans)/2*2+(cnt2-ans)/2*2+((cnt1-ans)&1)*3<<endl;
	return 0;
}

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

int main(){
  int n;
  string s,t;
  cin >>n >>s >>t;
  string st = " ";
  rep(i,n){
    st += s[i];
    st += t[i];
  }
  cout <<st << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <sstream>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
/*int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( ＊(double＊)p > ＊(double＊)q ) return 1;if( ＊(double＊)p < ＊(double＊)q ) return -1;return 0;}
*/
int main(void){
   cin.tie(0);
   ios::sync_with_stdio(false);
   //unsigned long a,b,c,d,e;
   int ad,bd;
   //unsigned long f=0;
   //string st,tt,nt;
   //vi ad,bd,cd,dd;
   //vs A,W,B;
   //int X=0;
   //vs as,bs,cs,ds;
   vector<char> A;
   string a;
   int flag=0,nfl,ta,tb;
   cin>>ad>>bd;
   if((ad*bd)%2==0)printa("No");
   else printa("Yes");
   return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  LL i,N,a,t,ans=0;
  cin>>N;
  rep(i,N){
    a=1,t=0;
    while(i+1>=a)a*=10,t++;
    if(t%2)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 55;
int dp[maxN][3][3];
const int mod = (int)1e9 + 7;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (s1[0] == s2[0]) {
                if (i != j) continue;
                dp[0][i][j] = 1;
            }
            else {
                if (i != j) dp[0][i][j] = 1;
            }
        }
    }
    for (int i = 0; i + 1 < n; i++) {
        for (int a = 0; a < 3; a++) {
            for (int b = 0; b < 3; b++) {
                for (int c = 0; c < 3; c++) {
                    for (int d = 0; d < 3; d++) {
                        if ((s1[i] == s1[i + 1]) != (a == c)) continue;
                        if ((s2[i] == s2[i + 1]) != (b == d)) continue;
                        if ((s1[i + 1] == s2[i + 1]) != (c == d)) continue;
                        dp[i + 1][c][d] = sum(dp[i + 1][c][d], dp[i][a][b]);
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            ans = sum(ans, dp[n - 1][i][j]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  cout << (n < 1000 ? "ABC" : "ABD") << endl;
}


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

using namespace std;

int seen[100001];
const int mod = 1000000007;

int64_t dfs(map<int,int> &a,int n,int p){
  if(seen[p] != -1)return seen[p];
  if(p == n)return 1;
  int64_t res = 0;
  if(!a[p+1] && p+1 <= n)(res += dfs(a,n,p+1))%=mod;
  if(!a[p+2] && p+2 <= n)(res += dfs(a,n,p+2))%=mod;
  return seen[p] = res;
}

int main(){
  int n,m;
  cin >> n >> m;
  map<int,int> a;
  fill(seen,seen+n+1,-1);
  for(int i = 0;i < m;i++){
    int x;cin >> x;
    a[x]++;
  }
  int64_t res = dfs(a,n,0);
  cout << res;
  return 0;
}

Measured memory_bytes: 16256
require 'complex'
X = gets.to_i
arr = Array.new(X+1, false)
arr[1] = true
(2..Math.sqrt(X).floor).each{|i|
    _p = 1
    while i ** _p <= X do
        arr[i ** _p] = true
        _p += 1
    end
}
X -= 1 while !arr[X]
puts X

Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
ll gcd(ll a, ll b){
	if(a % b == 0)  return b;

	return gcd(b, a % b);
}

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll A, B;  cin >> A >> B;
	ll ans = B * (A / gcd(A, B));

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T, X;
  cin >> T >> X;
  cout << T * 1.0 / X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int X, Y, Z;
int main() {
    cin >> X >> Y >> Z;
    int num = 0;
    num = X / (Y+Z);
    int r = X % (Y+Z);
    if(r >= Z) {
        cout << num << endl;
    }else {
        cout << num-1 << endl;
    }
}

Measured memory_bytes: 256