akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        StringBuilder T = new StringBuilder();
        for(int i=0;i<S.length();i++){
            T.append("x");
        }
        System.out.println(T);
}
}

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

int set_bit_count(int n) {
  int n1 = ((n  & 0b0101010101010101010101010101010) >> 1) +
            (n  & 0b1010101010101010101010101010101);
  int n2 = ((n1 & 0b1001100110011001100110011001100) >> 2) +
            (n1 & 0b0110011001100110011001100110011);
  int n3 = ((n2 & 0b1110000111100001111000011110000) >> 4) +
            (n2 & 0b0001111000011110000111100001111);
  int n4 = ((n3 & 0b1111111000000001111111100000000) >> 8) +
            (n3 & 0b0000000111111110000000011111111);
  int n5 = ((n4 & 0b1111111111111110000000000000000) >> 16) +
            (n4 & 0b0000000000000001111111111111111);
  return n5;
}

int main() {
  int N, M; cin >> N >> M;
  int A[M], B[M], C[M];
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    C[i] = 0;
    for (int j = 0; j < B[i]; j++) {
      int k; cin >> k;
      C[i] |= (1<<(k-1));
    }
  }
  int nodes_i[1<<N]; for (int i = 0; i < 1<<N; i++) nodes_i[i] = i;
  sort(nodes_i, nodes_i + (1<<N), [](int &a, int &b) {
    return set_bit_count(a) < set_bit_count(b);
  });
  int price[1<<N];
  for (int i = 0; i < 1<<N; i++) {
    if (i) price[i] = -1;
    else price[i] = 0;
  }
  for (int i = 0; i < 1<<N; i++) {
    int node_i = nodes_i[i];
    for (int j = 0; j < M; j++) {
      int head_i = node_i | C[j];
      int p = price[node_i];
      int head_p = p + A[j];
      if (p >= 0) {
        if (price[head_i] == -1) price[head_i] = head_p;
        else price[head_i] = min(price[head_i], head_p);
      }
    }
  }
  cout << price[(1<<N)-1] << endl;
}


Measured memory_bytes: 256
while True:
    solid = sorted(map(int, raw_input().split()))
    if solid.count(0) == 3: break
    n = input()
    s = (solid[0]**2+solid[1]**2)/4
    for i in range(n):
        r = input()
        if r*r > s:
            print 'OK'
        else:
            print 'NA'

Measured memory_bytes: 4200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		String s = "APPROVED";
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			if(A[i]%2==0 && !(A[i]%3==0 || A[i]%5==0)) {
				s = "DENIED";
			}
		}
		sc.close();
		System.out.println(s);
	}

}

Measured memory_bytes: 23892
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
    System.out.println((A * B * C) / (Math.max(Math.max(A, B), C) * 2));
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	int n,k,s;
	cin >> n >> k >> s;
	if (s == int(1e9)) {
		rep(i,k) cout << s << ' ';
		rep(i,n-k) cout << 1 << ' ';
	} else {
		rep(i,k) cout << s << ' ';
		rep(i,n-k) cout << s+1 << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int flag=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='C'){
      for(int j=i;j<s.size();j++){
        if(s.at(j)=='F')flag=1;
        if(flag==1)break;
      }
    }
    if(flag==1)break;
  }
  if(flag==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h],
    }

    let mut ans = 0;
    for i in 0..2usize.pow((h + w) as u32) {
        let mut num = 0;
        for row in 0..h {
            if i >> row & 1 != 0 {
                continue;
            }
            for col in 0..w {
                if i >> (h + col) & 1 != 0 {
                    continue;
                }
                if c[row][col] == '#' {
                    num += 1;
                }
            }
        }

        if num == k {
            ans += 1;
        }
    }

    println!("{}", ans);
}


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

int main() {
    int n; cin >> n;
    vector<int> h(n, 0);
    for (int i = 0; i < n; i++) cin >> h[i];
    int left = 0, ans = 0;
    while (left < n) {
        while (left < n && h[left] == 0) {
            left++;
        }
        int right = left;
        while (right < n && h[right]) {
            h[right] -= 1;
            right++;
        }
        ans += (left != n);
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

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

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 760
/*input
10
33 18 45 28 8 19 89 86 2 4
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

const int MX = 1000005;

int f[MX];

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		f[a[i]]++;
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		f[a[i]]--;
		bool ok = true;
		for(int j = 1; j * j <= a[i]; j++) {
			if(a[i] % j != 0) continue;
			ok &= (!f[j]);
			ok &= (!f[a[i] / j]);
		}
		ans += ok;
		f[a[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = a, i##_len = (b); i < i##_len; ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define cauto const auto &
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define SUM(v) accumulate((v).begin(), (v).end(), (ll)0)
#define INF 1000000000000
#define MOD 1000000007
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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;
}

const char newl = '\n';

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
ll qp(ll a, ull b) {
    ll ans = 1;
    do {
        if (b & 1u) ans *= a;
        a *= a;
    } while (b >>= 1u);
    return ans;
}
ll qp(ll a, ull b, ll mod) {
    ll ans = 1;
    do {
        if (b & 1u) ans = ans * a % mod;
        a = a * a % mod;
    } while (b >>= 1u);
    return ans;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll comb(int n, int r) {
    vector<vector<ll> > v(n + 1, vector<ll>(r + 1, 0));
    for (int i = 0; i < n + 1; i++) {
        v[i][0] = 1;
        if (i < r + 1) v[i][i] = 1;
    }
    for (int i = 1; i < n + 1; i++) {
        for (int j = 1; j < min(i, r + 1); j++) {
            v[i][j] = v[i - 1][j - 1] + v[i - 1][j];
        }
    }
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)

int main() {
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    vector<ll> xs, ys, zs;
    rep(i, n) {
        ll x, y, z;
        cin >> x >> y >> z;
        xs.push_back(x);
        ys.push_back(y);
        zs.push_back(z);
    }

    vector<ll> sums;
    ll total_max = -INF;
    rep(a, 2) {
        rep(b, 2) {
            rep(c, 2) {
                rep(i, n) {
                    ll x = a ? -xs[i] : xs[i];
                    ll y = b ? -ys[i] : ys[i];
                    ll z = c ? -zs[i] : zs[i];
                    sums.push_back(x + y + z);
                }
                RSORT(sums);
                ll total = 0;
                rep(i, m) { total += sums[i]; }
                total_max = max(total, total_max);
                sums.clear();
            }
        }
    }

    cout << total_max << newl;

    return 0;
}


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

#include <math.h>
#define PI 3.14159265358979323846264338327950L

vector<pair<long long, long long>> P;

void fill(long long n) {
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            P.push_back(make_pair(i, n / i));
        }
    }
}


int main() {
    long long n;
    cin >> n;
    fill(n);
    long long ans = INF;
    for (auto p : P) {
        ans = min(ans, p.first - 1 + p.second - 1);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
	int a,n=0;
	int low[10];
	for(;;){
		if(scanf("%d",&a)==EOF){break;}
		if(a==0){
			n--;
			printf("%d\n",low[n]);
		}
		else{
			low[n]=a;
			n++;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
   int a,b;
  cin>>a>>b;
  vector<int> c(b),e(b);
  int d[20][20];
  rep(i,b){
  cin>>c[i];
    rep(j,c[i])
      cin>>d[i][j];
  }
  rep(i,b)
    cin>>e[i];
  int ans=0;
  rep(i,(1<<10)){
  bitset<10> bit(i);
  vector<bool> t(b,0);
    rep(j,b){
    int p=0;
      rep(k,c[j]){
      if(bit.test(d[j][k]-1))
        p++;
        }
      if(p%2==e[j])
        t[j]=1;
    }
    bool cnt=1;
    rep(j,b){
      if(!t[j])
        cnt=0;
        }
    if(cnt)
      ans++;
  }
  int w=pow(2,10-a);
  cout<<ans/w<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        
        static int Solve(string X, string Y)
        {
            int xn = X.Length;
            int yn = Y.Length;

            int[,] dp = new int[xn + 1, yn + 1];

            dp[0, 0] = 0;
            
            for(int i = 1; i <= xn; i++)
            {
                for(int j = 1; j <= yn; j++)
                {
                    if(X[i - 1] == Y[j - 1])
                    {
                        dp[i, j] = dp[i - 1, j - 1] + 1;
                    }
                    else
                    {
                        dp[i, j] = Math.Max(dp[i - 1, j], dp[i, j - 1]);
                    }
                }
            }

            return dp[xn, yn];
        }



        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for(int i = 0; i < n; i++)
            {
                string X = Console.ReadLine();
                string Y = Console.ReadLine();

                Console.WriteLine(Solve(X, Y));
            }
                      
        }
    }
}


Measured memory_bytes: 35008
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; 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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;

	cout << a[k-1] << '\n';
	return 0;
}



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

int main() {
  ll n;cin>>n;
  ll p=0;
  string s="Yes";
  vector<ll>h(n);
  for(ll i=0;i<n;i++)
    cin>>h.at(i);
  for(ll i=0;i<n;i++)
  {
    p=max(p,h.at(i));
    if(p-h.at(i)>=2)
      s="No";
  }
  cout<<s;
}
  
 


Measured memory_bytes: 1024
#include <cstdio>

#define int long long

static const int N = 100005;
int a[N];

signed main() {
  int n; scanf("%lld", &n);
  for (int i = 0; i < n; ++ i) scanf("%lld", &a[i]);
  int l = 2, r = 2;
  for (int i = n - 1; ~ i; -- i) {
    l = ((l - 1) / a[i] + 1) * a[i];
    if (l > r) {
      printf("-1\n"); return 0;
    }
    r = (r / a[i] + 1) * a[i] - 1;
  }
  printf("%lld %lld\n", l, r);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

int main(void) {
  long long int x;
  long long int a,b;
  scanf("%lld", &x);
  //scanf("%d", &b):
  int m;
  int tmp;
  int flag=0;

  for(int i = 0;i<120;i++){
    a = i;
    tmp = a;
    a = a*a*a*a*a;
    b = a-x;
    if(b > 0){

      for(int j = 1;j<120;j++){
        int c = 0;
        c = b-(j*j*j*j*j);
        if(c == 0){
          m = j;
          flag =1;
          break;
        }
        }
        if(flag == 1){
          break;
      }
    }
    else{
    for(int k = -1;k > -120;k--){
      int d = 0;
      d = b-(k*k*k*k*k);
      if(d == 0){
        m = k;
        flag =1;
        break;
      }
    }
    if(flag == 1){
      break;
    }
  }

  }
  printf("%d %d\n",tmp,m);



  return 0;
}


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

int xi(int a, int b){
    int x;
    x = a%b;
    while(x != 0){
        a = b;
        b = x;
        x = a % b;
        
    }
    return b;
}

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


    cout << xi(a,b) << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, H;
  cin >> N >> H;
  vector<long> data(N);
  long a, maxsow = -1;
  for(int i = 0; i < N; i++){
    cin >> a >> data.at(i);
    maxsow = max(maxsow,a);
  }
  sort(data.begin(), data.end());
  int ans = 0, hp = 0, flag = 0;
  for(int i = N - 1; i >= 0; i--){
    if(data.at(i) > maxsow){
      hp += data.at(i);
      ans++;
      if(hp >= H){
        flag = 1;
        break;
      }
    } else {
      break;
    }
  }
  if(flag == 1)cout << ans << endl;
  else cout << ans + (H - hp - 1) / maxsow + 1<< endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long sum = 0;
    for(long long i = 0; i < n + 1; i++){
        if(i % 15 == 0){
            continue;
        }
        else if(i % 3 == 0){
            continue;
        }
        else if(i % 5 == 0){
            continue;
        }
        else{
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>

using namespace std;

typedef long long ll;

ll solve(ll n, ll m){
	if(n == 1 && m == 1) return 1;
	if(n == 1) return m - 2;
	if(m == 1) return n - 2;
	return (n - 2) * (m - 2);
}

int main(){
	ll n, m; scanf("%lld %lld", &n, &m);
	printf("%lld\n", solve(n, m));
	return 0;
}

Measured memory_bytes: 128
using Training20200611.Questions;
using Training20200611.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Training20200611.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/agc005/tasks/agc005_a
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var x = inputStream.ReadLine();
            var stack = new Stack<char>();

            foreach (var xi in x)
            {
                if (stack.Count > 0 && stack.Peek() == 'S' && xi == 'T')
                {
                    stack.Pop();
                }
                else
                {
                    stack.Push(xi);
                }
            }

            yield return stack.Count;
        }
    }
}


namespace Training20200611
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Training20200611.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Training20200611.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 12896
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
INF = float('inf')

N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (K+1)
for i in range(K+1):
    for j in range(N):
        if a[j] <= i:
            dp[i] |= dp[i-a[j]] == 0
ans = 'First' if dp[K] else 'Second'
print(ans)


Measured memory_bytes: 41836
def gcd(x, y):
    while True:
        x, y = y, x % y
        if y == 0:
            break
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


a, b, c, d = map(int, input().split())

n_c = b // c - (a - 1) // c
n_d = b // d - (a - 1) // d

e = lcm(c, d)
n_e = b // e - (a - 1) // e

print(b - a + 1 - (n_c + n_d - n_e))

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double pi = acos(-1.0);
  double S = x/a;
  
  if( a*b/2 < S ){
    //printf( "%lf", atan( (a*b-S)*2/(a*a) )*180.0/pi );
    printf( "%lf", atan2( (a*b-S)*2, (a*a) )*180.0/pi );
    }else if( a*b/2 == S ){
    //printf( "%lf", atan( b/a )*180.0/pi );
    printf( "%lf", atan2( b, a )*180.0/pi );
   }else{
    //printf( "%lf", atan( b*b/S*2 )*180.0/pi );
    printf( "%lf", atan2( b*b, S*2 )*180.0/pi );
  }
  return 0;
}


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

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

using namespace std;
char s[600][600];

int main(){
  int n;
  cin >> n;
  REP(i, n) REP(j, n){
    cin >> s[i][j];
    s[i+n][j+n] = s[i+n][j] = s[i][j+n] = s[i][j];
  }
  int res=0;
  REP(i, n){
    bool isGood = true;
    REP(j, n) REP(k, j) if(s[j][i+k] != s[k][i+j]) isGood = false;
    if(isGood) res += n;
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
    int i = 0;
    string  O,E;
    cin >> O >> E;

    while(E[i] != '\0'){
        cout << O[i] << E[i];
        i++;
    }
    if(O[i] != '\0'){
        cout  << O[i] << endl;
    }
    else {
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int sosuu[10000];
    int i,j,k;
    int n;
    sosuu[0]=2;
    for(i=3,j=1;j<10000;i+=2) {
        for(k=0;k<j;k++) {
            if(i%sosuu[k]==0)break;
        }
        if(k>=j) {
            sosuu[j]=i;
            j++;
        }
    }
    for(i=1;i<10000;i++)sosuu[i]+=sosuu[i-1];
    while(1) {
        scanf("%d",&n);
        if(n==0)break;
        printf("%d\n",sosuu[n-1]);
    }
    return 0;
}

Measured memory_bytes: 636
l = []
while True:
  a, op, b = list(map(str, input().split(' ')))
  a, b = [int(a), int(b)]
  ans = 0
  if op == '?':
    break
  if op == '+':
    ans = a + b
  if op == '-':
    ans = a - b
  if op == '/':
    ans = int(a / b)
  if op == '*':
    ans = a * b
  l.append(ans)
for n in l:
  print(n)


Measured memory_bytes: 5600
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int A, B;
	cin >> A >> B;
	int sum = 0;
	FOR(i,A,B + 1){
		int N = i;
		int d1, d2, d4, d5;
		d1 = N % 10;
		N /= 10;
		d2 = N % 10;
		N /= 100;
		d4 = N % 10;
		N /= 10;
		d5 = N % 10;
		if (d1 == d5 && d2 == d4) sum++ ;
	}
	cout << sum << endl;
	
	return 0;
}


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;
typedef std::pair<int,int> ipair;

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

    if (s.length() +1 == t.length()) {
        if (t.compare(0,s.length(), s) == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s.size()%2==1) {
        cout << "No" << "\n";
        return 0;
    }
    for(int i=0; i<s.size()-1; i+=2) {
        if (s[i]=='h' && s[i+1] == 'i') {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
} 

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
void nosol(){puts("-1");exit(0);}
int dist[333][333],n,mn[333][333];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
	{
		get1(dist[i][j]);
		if(i!=j&&!dist[i][j])nosol();
	}
	memset(mn,-1,sizeof(mn));
	for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
	{
		if(k==i||k==j)continue;
		if(dist[i][k]+dist[k][j]<dist[i][j])nosol();
		if(mn[i][j]==-1||mn[i][j]>dist[i][k]+dist[k][j])mn[i][j]=dist[i][k]+dist[k][j];
	}
	LL ans=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(mn[i][j]!=dist[i][j])ans+=dist[i][j];
	printendl(ans>>1);
	return 0;
}

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

int main(){
  int n,l;
  cin >> n >> l;
  vector<int> v(n);
  int apmin = 1000,op = 1;
  rep(i,n){
    v.at(i) = l + i;
    apmin = min(apmin , abs(v.at(i)));
    if(l+i<0) op = -1;
  }
  
   cout << n*(n+1)/2+n*(l-1)-apmin*op;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

d = {}
for i in a:
    if(i in d):d[i] += 1
    else:d[i] = 1
t = 0
for k,v in d.items():
    t += (v * (v-1)) // 2
for i in range(n):
    v = d[a[i]]
    s = t - (v * (v-1)) // 2 + ((v-1) * (v-2))//2
    print(s)

Measured memory_bytes: 24748
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
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 INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[30][51000];

int main(){
    ll n,w;
    cin >> n >> w;
    ll val[n],wei[n];
    for (ll i=0;i<n;i++)cin >> val[i] >> wei[i];
    ll dp[n+1][w+1],ans=0;
    for (ll i=0;i<=n;i++){
        fill(dp[i],dp[i]+w+1,0);
    }
    for (ll i=0;i<n;i++){
        for (ll j=0;j<=w;j++){
            chmax(dp[i+1][j],dp[i][j]);
            if (j+wei[i]<=w){
                chmax(dp[i+1][j+wei[i]],dp[i][j]+val[i]);
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 10980
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

class KnapsackBBSolver {
 private:
  using P = pair<ll, ll>;
  ll W, best;
  vector<P> ps;

 public:
  KnapsackBBSolver(ll W_) : W(W_) {}

  void addItem(ll v, ll w, ll m) {
    ll num = m;
    for (ll k = 1; num > 0; k <<= 1) {
      ll mul = min(num, k);
      if (mul * w > W) break;
      ps.emplace_back(mul * v, mul * w);
      num -= mul;
    }
  }

  ll solve() {
    optimize();
    best = 0;
    dfs(0, 0, W);
    return best;
  }

 private:
  void optimize() {
    sort(ps.begin(), ps.end(), [&](const P& a, const P& b) {
      auto x = __int128(a.fst) * b.snd;
      auto y = __int128(b.fst) * a.snd;
      if (x != y) return x > y;
      return a.fst > b.fst;
    });
  }

  pair<ll, bool> upper_bound(int i, ll W) {
    ll res = 0;
    bool integer = true;
    for (; i < ps.size() && W > 0; i++) {
      if (ps[i].snd > W) {
        res += __int128(ps[i].fst) * W / ps[i].snd;
        integer = false;
      } else {
        res += ps[i].fst;
      }
      W -= ps[i].snd;
    }
    return make_pair(res, integer);
  }

  void dfs(int i, ll V, ll W) {
    if (W < 0) return;
    if (i >= ps.size()) {
      if (V > best) best = V;
      return;
    }
    auto ub = upper_bound(i, W);
    if (V + ub.fst <= best) return;
    if (ub.snd) {
      best = V + ub.fst;
      return;
    }
    dfs(i + 1, V + ps[i].fst, W - ps[i].snd);
    dfs(i + 1, V, W);
  }
};

int main() {
  int N;
  ll X, D;
  while (cin >> N >> X >> D) {
    vector<ll> m(N);
    cin >> m[0];
    vec<int, 2> G(N);
    for (int i = 1; i < N; i++) {
      int p;
      cin >> m[i] >> p;
      --p;
      G[p].push_back(i);
    }
    vector<int> sz(N);
    vector<ll> msum(N);
    function<void(int)> dfs = [&](int v) {
      sz[v] = 1;
      msum[v] = m[v];
      for (int u : G[v]) {
        dfs(u);
        sz[v] += sz[u];
        msum[v] += msum[u];
      }
    };
    dfs(0);
    KnapsackBBSolver solver(X);
    for (int i = 0; i < N; i++) {
      ll lim = D;
      if (i == 0) lim = X / msum[0];
      solver.addItem(sz[i], msum[i], lim);
    }
    cout << solver.solve() << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 400000;
int for_erat[N];
vector<int> prime;
vector<int> v;
vector<int> res;


void erat(){
    for(int i = 0; i < N; i++){
        for_erat[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(for_erat[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                for_erat[i *(j + 2)] = 0;
            }
        }
    }

    for(int i = 2; i < N; i++){
        if(for_erat[i]){
            prime.push_back(i);
        }
    }
}

int main(){
	erat();

while(1){//start
	//init
	v.clear();
	res.clear();


	int n, p;
	cin >> n >> p;
	if(n == -1 and p == -1) break;

	//n以上の素数を15個見つける
	int idx = 0;
	while((int)v.size() != 50){
		if(prime[idx] > n) v.push_back(prime[idx]);
		idx++;
	}

	for(int i = 0; i < (int)v.size(); i++){
		for(int j = i; j < (int)v.size(); j++) res.push_back(v[i] + v[j]);
	}

	sort(res.begin(), res.end());
	//res.erase(unique(res.begin(), res.end()), res.end());

	cout << res[p-1] << endl;
	//for(int i = 0; i < (int)res.size(); i++) cout << res[i] << endl;


}//end
	return 0;

}



Measured memory_bytes: 4768
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long x) {
  if (x < 7) {
    cout << 1 << endl;
    return;
  } else if (x <= 11) {
    cout << 2 << endl;
    return;
  }

  ll ans = (x / 11) * 2;
  ll buf = x % 11;

  if (buf > 0)
    ans += buf <= 6 ? 1 : 2;

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long x;
  cin >> x;
  solve(x);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    queue<char> que;
    ll n;
    int i;
    cin >> n;
    vector<ll> twentysix(12);
    ll y = 0;
    ll x = 1;
    twentysix.at(0) = 0;
    for(i = 1; i < 12; i++){
        x *= 26;
        twentysix.at(i) = twentysix.at(i-1) + x;
        if(n <= twentysix.at(i)) break;
    }
    i--;
    x /= 26;
    ll a = n - twentysix.at(i) - 1;
    while(i > -1){
        if(a < x){
            x /= 26;
            i--;
            que.push('a');
            continue;
        }
        int c = a / x;
        a = a % x;
        x /= 26;
        i--;
        que.push(c + 'a');
    }
    while(!que.empty()){
        cout << que.front();
        que.pop();
    }
    cout << endl;
}

Measured memory_bytes: 30532
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='?')s[i]='D';
    }
    cout<<s<<"\n";
}


Measured memory_bytes: 3760
void main()
{
    string s = rdStr;

    string t = "AKIHABARA";
    string u;
    foreach (i, x; s)
    {
        if (i == 0 && x != 'A') u ~= 'A';
        if ((x == 'B' || x == 'R') && u.back != 'A') u ~= 'A';
        u ~= x;
        if (i == s.length - 1 && x == 'R') u ~= 'A';
    }

    writeln(t == u ? "YES" : "NO");
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# N本の竹それぞれA, B, C, 使わないか
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 **  5
for pattern in itertools.product(range(4), repeat=N):
    mp = 0
    Alist = []; Blist = []; Clist = []
    for i, p in enumerate(pattern):
        if p == 0:
            Alist.append(bamboo[i])
        elif p == 1:
            Blist.append(bamboo[i])
        elif p == 2:
            Clist.append(bamboo[i])
    if len(Alist) == 0 or len(Blist) == 0 or len(Clist) == 0:
        continue
    mp += 10 * (len(Alist) + len(Blist) + len(Clist) - 3)
    mp += abs(A - sum(Alist)) + abs(B - sum(Blist)) + abs(C - sum(Clist))
    if mp < answer:
        answer = mp

print(answer)
# 04

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
using namespace std;
const int MAX = 1200;
int H,W,N;
int sx,sy,res;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};//4个?找方向
char map[MAX][MAX];
int d[MAX][MAX];//??最短路的数?
typedef pair<int,int> P;
void BFS(int x,int y,char m)
{
    queue<P>  que;
    //初始状?入?
    que.push(P(x,y));
    d[x][y]=0;
    while(que.size())
    {
        //从?列最前端取出状?
        P p = que.front();
        que.pop();
        //若到?m点?束?找
        if(map[p.first][p.second]==m){
            sx=p.first;
            sy=p.second;
            return;
        }

        //四个方向循?
        for(int i=0;i<4;i++)
        {
            //?算移?后的位置
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(nx>=0&&nx<H&&ny>=0&&ny<W&&map[nx][ny]!='X'&&d[nx][ny]==-1)
            {
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }

}
void solve()
{
    for(int i=1;i<=N;i++)
    {
        memset(d,-1,sizeof(d));
        BFS(sx,sy,i+48);
        res+=d[sx][sy];
    }
    printf("%d\n",res);
}
int main()
{
    scanf("%d%d%d",&H,&W,&N);
    for(int i=0;i<H;i++)
        scanf("%s",map[i]);

    for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
    {
        if(map[i][j]=='S')
        {
            sx=i;sy=j;
            i=H;j=W;
        }
    }
    solve();
    return 0;
}

Measured memory_bytes: 8016
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int a,b,c;
	cin >> a >> b >> c;
	if(a>b){
		int temp=b;
		b=a;a=temp;
	}
	if(b>c){
		int temp=c;
		c=b;b=temp;
	}
	int count=0;
	count+=(c-a)/2+(c-b)/2;
	if((c-a)%2==1 || (c-b)%2==1){
		count+=2;
		if((c-a)%2==1 && (c-b)%2==1)count--;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
import io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)
  val avel = a.sum / n
  val aveh = avel + 1
  val resa = a.map(i => math.pow((i - avel),2).toInt).sum
  val resb = a.map(i => math.pow((i - aveh),2).toInt).sum
  val ans = math.min(resa, resb)
  println(ans)
}


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

int main() {
	int N;
	cin >> N;
	vector<string> vs(N);
	for (int i = 0; i < N; i++) {
		cin >> vs.at(i);
	}

	// 数え上げる。もっとスマートなやり方がある気がする
	map<string, int> mw;
	int max_count = 0;
	for (string s : vs) {
		if (mw.count(s)) {
			mw[s]++;
		}
		else {
			mw[s] = 1;
		}
		if (max_count < mw.at(s)) {
			max_count = mw.at(s);
		}
	}

	// 出力
	for (auto e : mw) {
		if (e.second == max_count) {
			cout << e.first << endl;
		}
	}
}


Measured memory_bytes: 26752
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY  1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{
    int v;
    color[u]=GRAY;
    d[u]=++tt;
    for(v=0;v<n;v++)
    {
        if(M[u][v]==0) continue;
        if(color[v]==WHITE)
            dfs_visit(v);
    }
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs()
{
    int u;
    for(u=0;u<n;u++)
        color[u]=WHITE;
    tt=0;
    for(u=0;u<n;u++)
        if(color[u]==WHITE)
            dfs_visit(u);
    for(u=0;u<n;u++)
        printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main()
{
    int u,v,k,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            M[i][j]=0;
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&u,&k);
        u--;
        for(j=0;j<k;j++)
        {
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    dfs();
    return 0;
}

Measured memory_bytes: 2716
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p[i];
  int cnt = 0;
  int tmp = 1e9;
  for(int i=0; i<n; i++) {
    tmp = min(tmp, p[i]);
    if (p[i] <= tmp) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

// EOF


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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int t, h;
	int n;
	cin >> n;
	vector<ll> a, b, c, d;
	if(n % 2 == 0){
		REP(i, n){
			cin >> t >> h;
			c.push_back(t*2);
			d.push_back(h*2);
		}
		sort(c.begin(), c.end());
		sort(d.begin(), d.end());
		REP(i, n-1){
			a.push_back((c[i] +c[i+1])/2);
			b.push_back((d[i] +d[i+1])/2);
		}
		n--;
	}
	else{
		REP(i,n){
			cin >> t >> h;
			a.push_back(t);
			b.push_back(h);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	/*
	REP(i, a.size()) cout << a[i] << " ";
	cout << endl;
	REP(i, b.size()) cout << b[i] << " ";
	cout << endl;
	cout << (n-1) - (n-1)/2 << " " << (n-1)/2 << endl; 
	*/
	cout << b[(n-1) - n/2] - a[n/2] + 1 << endl; 
}


Measured memory_bytes: 11204
#include <cstdio>

int M,N;
char flags[1002][1002];
char symbols[5][5];

int main() {
	scanf("%d%d",&M,&N);
	for(int i=0;i<M;i++) scanf("%s",flags[i]);
	for(int i=0;i<2;i++) scanf("%s",symbols[i]);
	int defsol=0;
	for(int i=0;i<M-1;i++) {
		for(int j=0;j<N-1;j++) {
			int exists=1;
			for(int x=0;x<2;x++) {
				for(int y=0;y<2;y++) {
					if(flags[i+x][j+y]!=symbols[x][y]) exists=0;
				}
			}
			defsol+=exists;
		}
	}
	int changemax=0;
	for(int i=0;i<M;i++) {
		for(int j=0;j<N;j++) {
			char def=flags[i][j];
			int deleted_emblems=0;
			int addmax=0;
			for(int x=-1;x<=0;x++) {
				for(int y=-1;y<=0;y++) {
					if(i+x>=0&&i+x+1<M) {
						if(j+y>=0&&j+y+1<N) {
							int exists=1;
							for(int v=0;v<2;v++) {
								for(int w=0;w<2;w++) {
									if(flags[i+x+v][j+y+w]!=symbols[v][w]) exists=0;
								}
							}
							deleted_emblems+=exists;
						}
					}
				}
			}
			for(int types=0;types<3;types++) {
				if(types==0) flags[i][j]='J';
				if(types==1) flags[i][j]='O';
				if(types==2) flags[i][j]='I';
				int addvl=0;
				for(int x=-1;x<=0;x++) {
					for(int y=-1;y<=0;y++) {
						if(i+x>=0&&i+x+1<M) {
							if(j+y>=0&&j+y+1<N) {
								int exists=1;
								for(int v=0;v<2;v++) {
									for(int w=0;w<2;w++) {
										if(flags[i+x+v][j+y+w]!=symbols[v][w]) exists=0;
									}
								}
								addvl+=exists;
							}
						}
					}
				}
				if(addmax<addvl) addmax=addvl;
			}
			if(changemax<addmax-deleted_emblems) changemax=addmax-deleted_emblems;
			flags[i][j]=def;
		}
	}
	printf("%d\n",changemax+defsol);
	return 0;
}

Measured memory_bytes: 2008