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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = i+1; i < (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T, typename M> T gcd(T a, M b) { if (b == 0) return a; return gcd(b, a % b); }

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll ans = 0;
  cin >> N;
  vector <int> A(N);
  map<int, int> tmp;
  map<int, int> m;
  rep(i, N) {
    cin >> A[i];
    tmp = prime_factor(A[i]);
    for (auto j = tmp.begin(); j != tmp.end(); j++) {
      if (m[j->_1] < j->_2)
        m[j->_1] = j->_2;
    }
  }
  ll t = 1;
  for (auto j = m.begin(); j != m.end(); j++) {
    t *= mod_pow((ll)j->_1, (ll)j->_2);
    t %= MOD;
  }
  rep(i, N) {
    ll temp = t;
    temp *= mod_pow((ll)A[i], MOD-2);
    temp %= MOD;
    // cout << temp << endl;
    ans += temp;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
using System;
using System.Linq;

namespace ABC133C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] LR = CIN.LongArray();

            for (long i = LR[0]; i <= LR[1]; i++)
            {
                if (i % 2019 == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }

            long min = 2018;
            for (long i = LR[0]; i < LR[1]; i++)
            {
                for (long j = i + 1; j <= LR[1]; j++)
                {
                    min = Math.Min(min, i % 2019 * (j % 2019) % 2019);
                }
            }
            
            Console.WriteLine(min);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13396
i,a[10],b[10],h,g,c,x;
main(n)
{ 
  for(scanf("%d",&n);n--;puts(x?"NO":"YES"))
    {
      for(a[0]=b[0]=h=g=i=x=0;i++<10;)
	{
	  scanf("%d",&c);
	  if(x)continue;
	  if(a[h]<c||b[g]<c)
	    if(a[h]<c&&(a[h]>b[g]||b[g]>=c))
	      a[++h]=c;
	    else
	      b[++g]=c;
	  else x=-1;
	}
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
int main() {
  int n,m,k;
  cin>>n>>m>>k;
  vector<long long>a(n+1);
  vector<long long>b(m+1);
  FOR(i,n){
    int x;
    cin>>x;
    a[i+1]=a[i]+x;
  }
  FOR(i,m){
    int x;
    cin>>x;
    b[i+1]=b[i]+x;
  }
  long long ans=0;
  int temp=m;
  for(long long i=0;i<=n;i++){
    for(long long j=temp;j>=0;j--){
      if(a[i]+b[j]<=k){
        ans=max(ans,i+j);
        temp=j;
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6428
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main(){
    int n,m,s;
    scanf("%d%d%d",&n,&m,&s);
    if (m == n){
        for (int i=0;i<n-1;i++) printf("%d ",s);
        printf("%d\n",s);
    }
    else{
        int temp;
        if (s == 1000000000) temp = 999999999;
        else temp = s+1;
        for (int i=0;i<m;i++) printf("%d ",s);
        for (int i=m;i<n-1;i++) printf("%d ",temp);
        printf("%d\n",temp);
    }
}

Measured memory_bytes: 3224
// ABC163D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

mint f(ll l, ll r) {
    return (l + r) * (r - l+1) / 2;
}

int main()
{
    ll n,k;
    cin >> n >> k;
    mint ans = 0;
    // N+1個の数があるから k個からn+1個まで合計する
    for (ll i = k; i <= n+1; i++) {
        mint mx = f(n - i + 1, n);
        mint mn = f(0, i - 1);
        ans += ( mx - mn  + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3196
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

long long d(int l, int r, const vector<long long>& v)
{
	return v[r] - v[l];
}

long long dLR(int l, int mid, int r, const vector<long long>& v)
{
	return abs(d(mid, r, v) - d(l, mid, v));
}

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

	vector<long long> A(N+1);
	for(int i=0; i<N; i++)
		cin >> A[i+1];

	for(int i=0; i<N; i++)
		A[i+1] += A[i];

	long long ret = LLONG_MAX;
	int left, right;
	left = 0;
	right = 1;
	vector<long long> v(4, 0);
	for(int i=1; i<N; i++){
		while(left < i && dLR(0, left+1, i, A) <= dLR(0, left, i, A))
			left++;

		while(right < N && dLR(i, right+1, N, A) <= dLR(i, right, N, A))
			right++;

		v[0] = d(0, left, A);
		v[1] = d(left, i, A);
		v[2] = d(i, right, A);
		v[3] = d(right, N, A);

		long long diff = *max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end());
		ret = min(ret, diff);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1792
N = int(input())
li=[6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp = [i for i in range(100010)]
for a in li:
    for x in range(a,N+1):
        dp[x] = min(dp[x],dp[x-a]+1)
print(dp[N])

Measured memory_bytes: 7064
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	unsigned int N, X, min = 10000, tmp;

	cin >> N >> X;

	for(int i = 0; i<N; i++) {
		cin >> tmp;
		X -= tmp;
		if(min > tmp)
			min = tmp;
	}

	cout << X/min + N;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};

P unit(const P &a){
    return a/abs(a);
}
double getangle(P a, P b){
    return abs(arg(a/b));
}
VP crosspointCC(C a, C b){
    VP ret;
    double dist = abs(b.p-a.p);
    P dir = a.r*unit(b.p-a.p);
    double cos = (a.r*a.r +dist*dist -b.r*b.r)/(2*a.r*dist);
    double sin = sqrt(1 -cos*cos);
    ret.push_back(a.p +dir*P(cos, sin));
    ret.push_back(a.p +dir*P(cos, -sin));
    return ret;
}

int main(){
    while(1){
        int n,q;
        double r;
        cin >> n >> r >> q;
        if(n==0) break;

        VP p(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            p[i] = P(x, y);
        }
        int st=-1;
        for(int i=0; i<n; i++){
            if(EQ(abs(p[i]), r)){
                st = i;
                break;
            }
        }

        for(int i=0; i<q; i++){
            double minangle = INF;
            int minidx = -1;
            P center = p[st];
            for(int j=0; j<n; j++){
                if(j == st) continue;
                VP cp = crosspointCC(C(center, abs(p[j] -center)), C(P(0,0), r));
                double angle = getangle(cp[0] -center, p[j] -center);
                if(angle < minangle){
                    minangle = angle;
                    minidx = j;
                }
            }
            P rot = P(cos(minangle), sin(minangle));
            st = minidx;
            for(int j=0; j<n; j++){
                p[j] -= center;
                p[j] *= rot;
                p[j] += center;
            }
            cout << fixed << setprecision(10);
            cout << p[st].X << " " << p[st].Y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3676
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  ll N, K;
  cin >> N >> K;

  N = N % K;
  ll MIN = N;
  REP(i,5){
    N = K-N;
    MIN = min(N,MIN);
  }


  cout << MIN << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

bool check_prime(int n) {
	if (n % 2 == 0) {
		if (n != 2)return false;
	}
	int r = sqrt(n);
	for (int i = 2; i <= r; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;;
}

int main() {
	int n,counter = 0;
	cin >> n;
	while (n--) {
		int a;cin >> a;
		if (check_prime(a)) counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 1160
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        x: [u64; n+1],
    }
    let mut x = x;

    // 隣り合う各都市間の距離を求める
    x.sort();
    let dis: Vec<_> = x.windows(2).map(|a| a[1] - a[0]).collect();

    // 隣り合う各都市間の最大公約数を求める
    fn gcd(_m: u64, _n: u64) -> u64 {
        let m = std::cmp::max(_m, _n);
        let n = std::cmp::min(_m, _n);

        if n == 0 {
            return m;
        }

        gcd(n, m % n)
    }

    let answer = dis.iter().fold(0, |gcf, x| gcd(gcf, *x));
    println!("{}", answer);
}


Measured memory_bytes: 6396
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

int main(){

  int n; cin >>n;
  int a[110000];
  int b[110000]={0};
  int c[110000]={0};
  for(int i=0;i<n;i++)
  {cin >>a[i];
   b[a[i]]++;
  }
  int ans=0;
  for(int i=1;i<100100;i++){
    c[i]=b[i-1]+b[i]+b[i+1];
    if(ans<c[i]) ans=c[i];
  }
  cout<<ans<<endl;
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int T = sc.nextInt();
			if (T == 0) break;
			int[] t = new int[T];
			for (int i = 0; i < T; ++i) {
				t[i] = sc.nextInt();
			}
			final int INF = 1 << 30;
			int N = sc.nextInt();
			int[] time = new int[101];
			Arrays.fill(time, INF);
			for (int i = 0; i < N; ++i) {
				int d = sc.nextInt();
				int m = sc.nextInt();
				time[d] = Math.min(time[d], m);
			}
			int[][] dp = new int[101][T];
			for (int[] a : dp) {
				Arrays.fill(a, INF);
			}
			dp[0][T - 1] = 0;
			for (int i = 1; i <= 100; ++i) {
				int m = time[i];
				for (int j = 0; j < T; ++j) {
					if (t[(j + 1) % T] <= m) dp[i][(j + 1) % T] = Math.min(dp[i][(j + 1) % T], dp[i - 1][j]);
					dp[i][0] = Math.min(dp[i][0], dp[i - 1][j] + 1);
				}
			}
			int ans = INF;
			for (int i = 0; i < T; ++i) {
				ans = Math.min(ans, dp[100][i]);
			}
			System.out.println(ans);
		}
	}
}

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

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

	priority_queue <int,vector<int>,greater<int>> pque;
	int n,t;
	multiset <int,greater<int>> s;
	vector <int> v;
	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	s.insert(v[0]);
	for(int i=1;i<n;i++)
	{
		auto it = s.upper_bound(v[i]);
		if(it!=s.end())
		{
			s.erase(s.find(*it));
			s.insert(v[i]);
		}
		else
		{
			s.insert(v[i]);
		}
	}

	cout << s.size() << '\n';

	return 0;
}



Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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 <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    VL A(N);
    REP(i,N) cin >> A[i];
    sort(A.begin(), A.end(), greater<LL>());
    LL ans = A[0];
    FOR(i,2,N){
        ans += A[i/2];
    }
    cout << ans << endl;

}

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

using namespace std;
int main()
{
  long long int k;
  cin>>k;
  char s[500];
  cin>>s;
  int p=strlen(s);
  if(p<=k)
  {
      cout<<s;
  }else
  {
      for(int i=0;i<k;i++)
      {
          cout<<s[i];
      }
      cout<<"...";
  }

  
}

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


void show(double x,double y){
  cout<< fixed << setprecision(8)<<x<<" "<<y<< fixed << setprecision(8)<<endl;
}
void koch(int n,double lx,double ly,double rx,double ry){
  double widx=rx-lx;
  double widy=ry-ly;
  if(n==0){
    show(lx,ly);
  }
  else if(n==1){
    show(lx,ly);
    show(lx+widx/3.0,ly+widy/3.0);
    show(lx+widx/2.0-widy*sqrt(3)/6.0,ly+widy/2.0+widx*sqrt(3)/6.0);
    show(lx+2.0*widx/3.0,ly+2.0*widy/3.0);
  }
  else{
    koch(n-1,lx,ly,lx+widx/3.0,ly+widy/3.0);
    koch(n-1,lx+widx/3.0,ly+widy/3.0,lx+widx/2.0-widy*sqrt(3)/6.0,ly+widy/2.0+widx*sqrt(3)/6.0);
    koch(n-1,lx+widx/2.0-widy*sqrt(3)/6.0,ly+widy/2.0+widx*sqrt(3)/6.0,lx+2.0*widx/3.0,ly+2.0*widy/3.0);
    koch(n-1,lx+2.0*widx/3.0,ly+2.0*widy/3.0,rx,ry);
  }
}

int main(){
  int n;
  cin>>n;
  koch(n,0.0,0.0,100.0,0.0);
  show(100.0,0.0);

  return 0;
}


Measured memory_bytes: 3212
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int N;
    char S[200001];
    int black = 0;
    int change = 0;
    int ans = 0;

    //input
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S[i];
        if(S[i] == '#'){
            black++;
        }
    }

    ans = black;
    change = black;
    for(int i = N - 1; i >= 0; i--){
        if(S[i] == '.'){
            change++;
        }else if(S[i] == '#'){
            change--;
        }
        if(change < ans){
            ans = change;
        }
    }

    //output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  int n, t, a;
  cin >> n >> t >> a;
  vi32 h(n);
  rep(i, n) cin >> h[i];
  int min_i = -1;
  f64 min_v = 1e9;
  rep(i, n) {
    f64 r = (f64) t - h[i] * 0.006;
    f64 s = fabs(r - a);
    if (min_v > s) {
      min_v = s;
      min_i = i;
    }
  }
  cout << min_i + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll Mod = 998244353;
const ll Inf = 2242545357980376863LL;
const ll Log = 20;
const ll N = 1ll << Log;
const int Maxn = 5e2 + 10;
const int Base = 101;

ll c1[30], c2[30];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(c2, 31 , sizeof c2);
	ll n;
	cin >> n;
	str s;
	for(int i = 0; i < n; i++){
		memset(c1, 0, sizeof c1);
		cin >> s;
		for(auto x : s) c1[x-'a'] ++;
		for(int j = 0; j < 30; j++) c2[j] = min(c2[j], c1[j]);
	}
	for(int j = 0; j < 30; j++) for(int i = 0; i < c2[j]; i++) cout << ((char)('a' + j));
	cout << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;

pair<ll, ll> mon[222222];
ll p[222222];

int main(void)
{
    ll n, d, a, i, j, ans = 0;

    scanf("%lld %lld %lld" ,&n, &d, &a);
    for (i = 1; i <= n; i++)
		scanf("%lld %lld" ,&mon[i].first, &mon[i].second);

	sort(mon + 1, mon + n + 1);

	for (i = 1; i <= n; i++)
	{
		p[i] += p[i - 1];

		mon[i].second += p[i];
		if (mon[i].second <= 0)
			continue;

		ll bomb = (mon[i].second + a - 1) / a;
		ans += bomb;

		mon[i].second = 0;
//		for (j = i + 1; j <= n; j++)
//			if (mon[j].first <= mon[i].first + 2 * d)
//                mon[j].second -= bomb * a;
		p[i] -= bomb * a;
		ll it = upper_bound(mon + 1, mon + n + 1, make_pair(mon[i].first + 2 * d, (ll)2e9)) - mon;

		p[it] += bomb * a;
	}

	printf("%lld" ,ans);
	return 0;
}

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

bool isprime(int n) {
	if (n==2 || n==3) return true;
	if (!(n%2)) return false;
	if (!(n%3)) return false;
	int lim = (int)sqrt((double)n) + 1;
	for (int i = 6; i <= lim; i += 6) {
		if (!(n%(i-1))) return false;
		if (!(n%(i+1))) return false;
	}
	return true;
}

int table[10000];

int main() {
	int k = 0;
	table[0] = 2;
	for (int i = 3, k = 1; k < 10000; i++) {
		if (isprime(i)) {
			table[k] = table[k-1] + i;
			k++;
		}
	}

	int n;
	while (cin >> n, n)
		cout << table[n-1] << endl;

	return 0;
}

Measured memory_bytes: 0
N,M = map(int,input().split())
K = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
#人ループ
for person in range(0,N):
    L = list(map(int,input().split()))
    for kind in range(1,L[0]+1):
        K[L[kind]] += 1
print(K.count(N))


Measured memory_bytes: 3064
N,M = list(map(int,input().split()))
A = [tuple(map(int,input().split())) for _ in range(N)]
sortA = sorted(A,key= lambda x: x[0])
ans = 0
for i in range(N):
    if M-sortA[i][1]>0:
        ans += sortA[i][0]*sortA[i][1]
        M = M-sortA[i][1]
    else:
        ans += M*sortA[i][0]
        break
print(ans)

Measured memory_bytes: 18892
#include<stdio.h>

int main(){
  int A,B,C;
  scanf("%d %d %d\n",&A,&B,&C);
  
  int i;
  i=A;
  A=B;
  B=i;
  i=A;
  A=C;
  C=i;
  
  printf("%d %d %d",A,B,C);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, k, mod;
int f[200][200], g[200][200];
map<int, int> mp1, mp2;

inline void addto(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}

void trans(int x, int y) {
	if (!x && !y) return;
	memset(g, 0, sizeof g);
	for (int i = 0; i <= k; ++i)
		for (int j = 0; j <= n; ++j) {
			addto(g[0][0], f[i][j]);
			if (x == 1) addto(g[i ? i + 1 : 0][0], f[i][j]);
			if (y == 1) addto(g[0][j + 1], f[i][j]);
			if (x == 1 && y == 1) addto(g[max(i, j) + 1][j + 1], f[i][j]);
		}
	memcpy(f, g, sizeof g);
}

void solve1() {
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i)
		if (i & 1) ++mp1[i];
		else ++mp2[i - k];
	for (int i = -1000; i <= 1000; ++i)
		trans(mp1[i], mp2[i]);
	int ans = 0;
	for (int i = 0; i <= k; ++i)
		for (int j = 0; j <= n; ++j)
			addto(ans, f[i][j]);
	printf("%d", ans);
}

void solve2() {
	f[0][0] = 1;
	k /= 2;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= k; ++j) {
			addto(f[i + 1][j + 1], f[i][j]);
			addto(f[i + 1][0], f[i][j]);
		}
	int a1 = 0, a2 = 0;
	for (int i = 0; i <= k; ++i) {
		addto(a1, f[n / 2][i]);
		addto(a2, f[(n + 1) / 2][i]);
	}
	printf("%lld", 1ll * a1 * a2 % mod);
}

int main() {
	scanf("%d%d%d", &n, &k, &mod);
	if (k & 1) solve1();
	else solve2();
}


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

int main() {
  string n;
  cin >> n;
  int ans = 0;
  int num = n.size();
  for(int i = 0; i < num; i++){
    if(n[i] == '1'){ ans += 1;
        continue;
    }if(n[i] == '2'){ ans += 2;
        continue;
    }if(n[i] == '3'){ ans += 3;
        continue;
    }if(n[i] == '4'){ ans += 4;
        continue;
    }if(n[i] == '5'){ ans += 5;
        continue;
    }if(n[i] == '6'){ ans += 6;
        continue;
    }if(n[i] == '7'){ ans += 7;
        continue;
    }if(n[i] == '8'){ ans += 8;
        continue;
    }
  }
  
  if(ans % 9) cout << "No" << endl;
  else cout << "Yes" << endl;
  
return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    public class Node
    {
        internal Node(int val)
            : this(val, new List<Node>())
        {
        }

        internal Node(int val, List<Node> children)
        {
            this.Value = val;
            this.Children = children;
        }

        public int Value { get; set; }
        public List<Node> Children { get; set; }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var M = items[1];
            var nodes = Enumerable.Range(1, N).ToDictionary(elem => elem, elem => new Node(elem));
            foreach (var i in Enumerable.Range(0, M))
            {
                var items2 = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
                var A = items2[0];
                var B = items2[1];
                nodes[A].Children.Add(nodes[B]);
                nodes[B].Children.Add(nodes[A]);
            }

            var queue = new Queue<Node>(N);
            queue.Enqueue(nodes[1]);
            var answer = new Dictionary<int, int>();
            while (queue.Count != 0)
            {
                var current = queue.Dequeue();
                foreach (var child in current.Children)
                {
                    if (!answer.ContainsKey(child.Value))
                    {
                        answer[child.Value] = current.Value;
                        queue.Enqueue(child);
                    }
                }
            }

            var answerList = new List<string>();
            try
            {
                foreach (var i in Enumerable.Range(2, N - 1))
                {
                    answerList.Add(answer[i].ToString());
                }
            }
            catch (Exception)
            {
                answerList = null;
            }

            if (answerList == null)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
                answerList.ForEach(elem => Console.WriteLine(elem));
            }
        }
    }
}


Measured memory_bytes: 65584
n = int(input())
s = [input() for i in range(n)]
c0, c1, c2, c3 = 0, 0, 0, 0
for i in s:
    if i == 'AC':
        c0 += 1
    elif i == 'WA':
        c1 += 1
    elif i == 'TLE':
        c2 += 1
    else:
        c3 += 1
print('AC x', c0)
print('WA x', c1)
print('TLE x', c2)
print('RE x', c3)

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

typedef long long int ll;
ll n;

int main() {
    cin >> n;

    ll res = 0;
    for(ll i = 1; i <= n; ++i) {
        if(i%3 != 0 && i%5 != 0) res += i;
    }

    cout << res << endl;

    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int64 lcm(int64 a, int64 b){
  return a / __gcd(a,b) * b;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n,m;
  cin >> n >> m;
  int64 l = 1;
  vector<int64> a(n);
  REP(i,n){
    cin >> a[i];
    a[i] >>= 1;
    l = lcm(l, a[i]);
    if(l > m){
      ANS(0);
      return 0;
    }
  }
  REP(i,n){
    if(l % (a[i] * 2) == 0){
      ANS(0);
      return 0;
    }
  }
  ANS((m / l + 1) / 2);
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;
  const ll inf = 1e18;
  vvl dp(n+5, vl(2, -inf));
  vl a(n+5, -inf);
  rep(i,0,n) cin >> a[i];
  dp[0][0] = a[0];
  dp[1][0] = a[1];
  dp[1][1] = a[1];
  dp[2][1] = a[2];
  rep(i,0,n) {
    rep(j,0,2) {
      if (j and (n%2==0)) break;
      if (dp[i][j] == -inf) continue;
      ckmax(dp[i+2][j], dp[i][j]+a[i+2]);
      if (((i%2)^(j))==0) ckmax(dp[i+3][j], dp[i][j]+a[i+3]);
      if (j==0 and n%2==1) ckmax(dp[i+1][1], dp[i][j]);
    }
  }

  cout << max(*max_element(all(dp[n-2])), *max_element(all(dp[n-1]))) << '\n';
}

Measured memory_bytes: 15852
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a=100000,n;
	cin>>n;
	while(n-->0){
		a*=1.05;
		a=(a+999)/1000;
		a*=1000;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 1160
use std::io::*;
use std::cmp::*;

fn main() {
	let a = read();
	let b = read();
	let c = read();
	let d = read();

	println!("{}", min(a, b) + min(c , d));
}


fn read() -> usize {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

ll h;

struct pt{
    ll x,y;
};

vi P;


ll PROD[MAXN][20] = {0};

int pp(ll i){
    return P[i-(1 << (h-1))] + (1 << (h-1));
}

ll C[MAXN] = {0};
int CC1[MAXN] = {0};
int cc1 = 0;
vi NEW1 = {0};
void reset(){
    trav(i,NEW1){
        C[i] = 0;
    }
    cc1++;
    NEW1.clear();
}

void add(ll p, ll to){
    C[to] += p;
    C[to] %= big;
    if(CC1[to] != cc1){
        CC1[to] = cc1;
        NEW1.push_back(to);
    }
    //cerr << "ADD: "  << p << " to: " << to << "\n";
}

void dfs(ll i, ll p, int start){
    while(i > 0){
        p *= i;
        p %= big;
        if(i > 1){
            ll other = (i/2)*2;
            if(other == i)other++;
            add((p*(i/2)), other);
        }

        if(i == 1)return;
        i /= 2;
    }
}

void setup(ll i, ll p){
    ll jj = i;
    ll nums = 1;
    ll b = 0;
    while(jj < (1 << (h-1))){
        jj *= 2;
        nums *= 2;
        b++;
    }

    rep(c1,0,nums){
        dfs(pp(jj+c1), PROD[jj+c1][b], i);
    }

}


int CC2[MAXN] ={0};
int cc2 = 0;

ll solve(ll i){
    reset();
    setup(2*i+1,1);
    ll j = i;

    ll nums = 1;
    while(j < (1 << (h-1))){
        j *= 2;
        nums *= 2;
    }
    nums /= 2;

    ll ans = 0;

    ll ppp = 0;
    ll jjj = i;
    while(jjj < (1 << (h-1))){
        jjj*=2;
        ppp++;
    }

    for(ll c1 = 0; c1 < nums; c1++){
        ll j2 = j+c1;
        cc2++;
        ll prod = 1;
        ll j3 = j2;

        prod = PROD[j3][ppp];

        j3 = pp(j2);

        while(j3 > 0){

           prod *= j3;
            prod %= big;
            ans += prod*C[j3];
            ans %= big;
            j3 /= 2;
        }

    }
    return ans;
}

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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> h;
    n = (1 << h)+1;


    for(ll c1 = 1; c1 < (1 << h)+1; c1++){
        ll p = c1;
        ll c2 = c1;
        PROD[c1][0] = p;
        for(ll c3 = 1; c3 < 20; c3++){
            c2 /= 2;
            p *= c2;
            p %= big;
            PROD[c1][c3] = p;
        }
    }

    rep(c1,0,(1 << (h-1))){
        cin >> a;
        //a = c1+1;
        P.push_back(a-1);
    }

    ll ans = 0;
    rep(c1,1,(1 << (h-1))){
        ans += solve(c1);
        ans %= big;
    }

    cout << ans << "\n";

    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct chtime{
	chrono::system_clock::time_point stm;
	auto nget() { return chrono::system_clock::now();}
	chtime() { stm = nget();}
	uint64_t gtm(){
		return chrono::duration_cast<chrono::milliseconds>(nget()-stm).count();
	}
	void disp(){ cerr << gtm() <<"\n";}
};

// ローリングハッシュ
// 二分探索で LCP を求める機能つき
struct RollingHash {
	static const int base1 = 1007, base2 = 2009;
	static const int mod1 = 1000000007, mod2 = 1000000009;
	vector<ll> hs1, hs2, pw1, pw2;

	RollingHash(const string &S) {
		int n = (int)S.size();
		hs1.assign(n+1, 0);
		hs2.assign(n+1, 0);
		pw1.assign(n+1, 1);
		pw2.assign(n+1, 1);
		for (int i = 0; i < n; i++) {
			hs1[i+1] = (hs1[i] * base1 + S[i]) % mod1;
			hs2[i+1] = (hs2[i] * base2 + S[i]) % mod2;
			pw1[i+1] = (pw1[i] * base1) % mod1;
			pw2[i+1] = (pw2[i] * base2) % mod2;
		}
	}
	
	// get hs of S[left:right]
	pair<ll, ll> get(int l, int r)  {
		ll res1 = hs1[r] - hs1[l] * pw1[r-l] % mod1;
		if (res1 < 0) res1 += mod1;
		ll res2 = hs2[r] - hs2[l] * pw2[r-l] % mod2;
		if (res2 < 0) res2 += mod2;
		return {res1, res2};
	}

	int getLCP(int a, int b) {
		int len = min((int)hs1.size()-a, (int)hs1.size()-b);
		int low = 0, high = len;
		while (high - low > 1) {
			int mid = (low + high) >> 1;
			((get(a, a+mid) != get(b, b+mid))?  high: low) = mid;
		}
		return low;
	}
};

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

	RollingHash rh(S);

	int res = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i+res+1; j < N; ++j) {
			int lcp = rh.getLCP(i, j);
			lcp = min(lcp, j-i);
			res = max(res, lcp);
		}
	}   
		
	cout << res << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
int pre[26][200000];
signed main()
{
     SPEED;
     string s;
     cin>>s;
     int n=s.length();
     for(int i=0;i+1<n;i++)
     {
     	  if(s[i]==s[i+1])
     	  {
     	  	   cout<<i+1<<" "<<i+2<<endl;
     	  	   return 0;
     	  }
     }
     vector<int>count(26,0);
     for(int i=0;i<n;i++)
     {
     	  count[s[i]-'a']++;
     	  for(int j=0;j<26;j++)
     	  	pre[j][i]=count[j];
     }
     for(int i=0;i<n;i++)
     {
     	   for(int j=i+1;j<min(n,i+10);j++)
     	   {
     	   	   int mid=j;
     	   	   int length=mid-i+1;
     	   	   length/=2;
     	   	   length++;
     	   	   for(int j=0;j<26;j++)
     	   	   {
     	   	   	    int frequency=pre[j][mid];
     	   	   	    if(i>=1)
     	   	   	    	frequency-=pre[j][i-1];
     	   	   	    if(frequency>=length&&length>=2)
     	   	   	    {
     	   	   	    	  cout<<i+1<<" "<<mid+1<<endl;
     	   	   	    	  return 0;
     	   	   	    }
     	   	   }
     	   }
     }
     cout<<"-1 -1"<<endl;
     time();
     return 0;
}

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

using namespace std;

int main() {
    vector<int> abc = vector<int>(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    if (count(abc.begin(), abc.end(), 5) == 2
        && count(abc.begin(), abc.end(), 7) == 1)
    {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

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

int main() {
    int n, vi;
    cin >> n;
    map<int, int> even, odd;
    for (int i = 1; i <= n; i++) {
        cin >> vi;
        (i & 1 ? odd[vi] : even[vi])++;
    }

    int key_odd_max1, key_odd_max2, key_even_max1, key_even_max2;
    for (auto oddi : odd) {
        if (oddi.second > odd[key_odd_max1]) key_odd_max1 = oddi.first;
    }
    for (auto oddi : odd) {
        if (oddi.second > odd[key_odd_max2] && oddi.first != key_odd_max1) key_odd_max2 = oddi.first;
    }
    for (auto eveni : even) {
        if (eveni.second > even[key_even_max1]) key_even_max1 = eveni.first;
    }
    for (auto eveni : even) {
        if (eveni.second > even[key_even_max2] && eveni.first != key_even_max1) key_even_max2 = eveni.first;
    }

    int ans_odd, ans_even;
    if (key_odd_max1 != key_even_max1) {
        ans_odd = n / 2 - odd[key_odd_max1];
        ans_even = n / 2 - even[key_even_max1];
    } else {
        if (odd[key_odd_max2] > even[key_even_max2]) {
            ans_odd = n / 2 - odd[key_odd_max2];
            ans_even = n / 2 - even[key_even_max1];
        } else {
            ans_odd = n / 2 - odd[key_odd_max1];
            ans_even = n / 2 - even[key_even_max2];
        }
    }

    cout << (ans_odd + ans_even) << endl;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b >= c){
        cout << "No" << endl;
        return 0;
    }
    ll ab = a*b*4;
    ll left = (c-a-b)*(c-a-b);
    if(ab < left){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
	int n,k,x,y,sum=0;
	scanf("%d %d %d %d", &n,&k,&x,&y);

	if(n>k)
	{
		for(int i = 1; i <= k; i++)
		{
			sum += x;
		}
		for(int i = k+1; i <= n; i++)
		{
			sum += y;
		}
	} 
	else
	{
		for(int i = 1; i <= n; i++)
		{
			sum += x;
		}
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 2128
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

bool IsPrime(int m) {
  for (int i = 2; i * i <= m; i++) {
    if (m % i == 0) return false;
  }
  return true;
}

int main() {
  int n, m;
  cin >> n;
  int ans = 0;
  rep(i, n) {
    cin >> m;
    ans += IsPrime(m);
  }

  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

vector<pair<int, int>> G[100000];
int dist[100000];

void dfs(int u, int p) {
  for (auto e : G[u]) if (e.first != p) {
    dist[e.first] = (dist[u] + e.second) % 2;
    dfs(e.first, u);
  }
}

int main() {
  int N;
  cin >> N;
  REP(i, N - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    G[u].emplace_back(v, w);
    G[v].emplace_back(u, w);
  }
  dfs(0, -1);
  for (int i = 0; i < N; i++) {
    cout << dist[i] % 2 << '\n';
  }
}


Measured memory_bytes: 8320
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD=1e9+7;
const int INF=1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------//
void solve(){
   
   int n,m;
   cin>>n>>m;
   int ret=(n-1)*(m-1);
   cout<<ret<<endl;
    
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (auto &it : a) {
		cin >> it;
	}
	vector<int> cur = a;
	int ans = 1e18;
	for (int shift = 0; shift < n; shift++) {
		int sum = x * shift;
		for (int i = 0; i < n; i++) {
			cur[i] = min(cur[i], a[(i - shift + n) % n]);
			sum += cur[i];
		}
		ans = min(ans, sum);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  long p[a];
  long q[b];
  long r[c];
  int i;
  for(i=0;i<a;i++)cin>>p[i];
  for(i=0;i<b;i++)cin>>q[i];
  for(i=0;i<c;i++)cin>>r[i];

  sort(p,p+a,greater<long>());
  sort(q,q+b,greater<long>());
  sort(r,r+c,greater<long>());

  int j = x-1;
  int k = y-1;
  for(i=0;i<c;i++){
    if(j>=0 && k>=0){
      if(p[j]>=q[k]){
        if(r[i]>q[k]){
          q[k]=r[i];
          k--;
        }
      }else{
        if(p[j]<r[i]){
          p[j]=r[i];
          j--;
        }
      }
    }else{
      if(k>=0){
        if(r[i]>q[k]){
          q[k]=r[i];
          k--;
        }
      }
      if(j >= 0){
        if(p[j]<r[i]){
          p[j]=r[i];
          j--;
        }
      }
    }

  }
  long ans = 0;
  for(i=0;i<x;i++)ans += p[i];
  for(i=0;i<y;i++)ans += q[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define mod 998244353
#define ll long long
using namespace std;
int n,a,b,q[300005],x[300005],ans;
ll k;
int pow(int c,int p){
	int tot=1;
	while(p){
		if(p&1) tot=1ll*c*tot%mod;
		c=1ll*c*c%mod;
		p>>=1;
	}
	return tot;
}
int C(int A,int B){
	if(A==0) return 1; if(A>B) return 0; if(A==B) return 1;
	return 1ll*q[B]*x[A]%mod*x[B-A]%mod;
}
int main(){
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	q[1]=1;for(int i=2;i<=n;++i) q[i]=1ll*q[i-1]*i%mod;
	x[n]=pow(q[n],mod-2);
	for(int i=n-1;i>=0;--i) x[i]=x[i+1]*1ll*(i+1)%mod;
	if(k==0){puts("1");return 0;}
	for(int i=1;i<=n;++i){
		ll j=k-1ll*i*a;
		if(j<0||j%b) continue;
		j/=b;
		ans=(ans+1ll*C(i,n)*C(j,n)%mod)%mod;
	}
	printf("%d",ans);
}


Measured memory_bytes: 2560