akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint a,b,n;
  cin>>a>>b>>n;
  lint d=min(n,b-1);
  cout<<(lint)floor((double)(a*d)/b)<<endl;

  return 0;
}




Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc120b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int k = int.Parse(s[2]);

            int i;

            for(i = 100; i > 0; i--)
            {
                if(a%i ==0 && b % i == 0)
                {
                    k--;
                }

                if (k == 0)
                {
                    break;
                }
            }

            Console.WriteLine(i);
        }
    }
}


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



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	int n;
	cin >> n;

	cout << 800 * n - (n / 15 * 200) << '\n';
	
	return 0;
}

Measured memory_bytes: 256
def reverse_str(s):
    return ''.join(list(s)[::-1])


words = list(map(reverse_str, 'dream dreamer erase eraser'.split()))
S = reverse_str(input())
ok = True
while S:
    for r in range(5, 8):
        tmp = S[:r]
        if tmp in words:
            # print(S, end=' => ')
            S = S[r:]
            # print(S)
            break
    else:
        ok = False
        break
print('YES' if ok else 'NO')


Measured memory_bytes: 4724
#include <iostream>
#include <limits.h>
using namespace std;

int main ()
{
	int n, pair = 0;
	cin >> n;
	for (int i = 0; i < n / 4 + 1; i++) {
	    if ((n - 4 * i) % 7 == 0) pair++;
	}
	if (pair > 0) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;
#include <map>

using ll = long long;
using namespace std;


int main(){
    int n; cin >> n;
    string S;
    cin >> S;
 
    ll r = 0, g = 0, b = 0;
    rep(i, n) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
    }
 
    ll ans = r * g * b;
    // cout << ans << endl;
 
    for(int l=1; l<n; l++) {
        rep(i, n){
            int j = i + l;
            int k = j + l;
            // 間隔の同じ数の中から条件１を満たすものを除外
            if (k < n && S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
                ans--;
            }
        }
    }
 
    cout << ans << endl;
    
}


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

ll a[200000],bit[500000];
void add(int k,int x){
	while(k<500000){
		bit[k]+=x;
		k+=k&-k;
	}
}
ll sum(int k){
	ll res=0;
	while(k){
		res+=bit[k];
		k-=k&-k;
	}
	return res;
}
ll b[200001];
int main() {
	ll n,k;scanf("%lld%lld",&n,&k);
	vector<ll>v{LLONG_MIN,0};
	rep(i,n){
		scanf("%lld",&a[i]);
		b[i+1]=b[i]+a[i]-k;
		v.push_back(b[i+1]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	ll ans=0;
	add((int)(lower_bound(v.begin(),v.end(),b[n])-v.begin()),1);
	for(int i=n-1;i>=0;i--){
		int c=lower_bound(v.begin(),v.end(),b[i])-v.begin();
		ans+=n-i-sum(c-1);add(c,1);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 8944
n = int(input())
x = input()
d = int(input())
swap = {}
for i in range(n):
  if d == 0:break
  if x[i] == "0":
   swap[i] = True
   d -= 1

for i in range(n - 1, -1, -1):
  if d == 0:break
  if x[i] == "1":
    swap[i] = True
    d -= 1
print("".join([x[i] if i not in swap else ("0" if x[i] == "1" else "1") for i in range(n)]))




Measured memory_bytes: 5656
n=int(input())
c=input()
n_R=c.count('R')
n_W=0
temp=n_R
ans=n_R
for i in range(n):
    if c[i]=='W':
        n_W+=1
    else:
        n_R-=1
    temp=max(n_W,n_R)
    ans=min(temp,ans)
ans=min(ans,c.count('W'))
print(ans)

    

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


using namespace std;

int main(){
    long long N,A,B,C,D;
    long long ans=0;

    string S;

    cin>>S;


    for (int i = 1; i < 4; i++)
    {
        if(S[i]==S[i-1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    
cout<<"Good"<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long[] A = new long[5];
        for(int i = 0; i < 5; i++){
            A[i] = sc.nextLong();
        }
        sc.close();
        long min = A[0];
        for(int i = 1; i < 5; i++){
            min = Math.min(min, A[i]);
        }
        if(N%min == 0)
            System.out.println(N/min + 4);
        else
            System.out.println(N/min + 5);
    }
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n;//n<=500
  cin >> n;
  vector<ll> C(n),S(n),F(n);//乗車時間、スタート時間、感覚
  rep(i,n)cin>>C.at(i)>>S.at(i)>>F.at(i);
  //再帰を使用したラムダ関数
  function<int(int,int)> destination_time = [&](int now, int i){
    int time;
    if(i==n-1) return now;
    if(now<=S.at(i)) time = S.at(i)+C.at(i);
    else time = S.at(i)+((now-S.at(i)-1)/F.at(i)+1)*F.at(i)+C.at(i);
    return destination_time(time,i+1);
  };

  rep(i,n)cout<<destination_time(0,i)<<endl;
  return 0;
}

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

long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for(long long i = 1;i <= n;i++){
    for(long long j = 1;j <= n;j++){
      long long t = gcd(i, j);
      for(long long k = 1;k <= n;k++){
        ans += gcd(t,k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>	// swapはalgorithmヘッダ swap(a,b); min,max
using namespace std;
#define INF 999999999
#define N 100000
#define ed "\n"
#define _dg cout << "debug" << ed;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int dp[N];
    int h[N];
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> h[i];
        dp[i]= INF;
    }
    
    dp[0]= 0;
    for(int i=0; i<n; i++){
        if(i+1<n){
            dp[i+1]= min(dp[i+1], dp[i] +abs(h[i+1]-h[i]));
        }
        if(i+2<n){
            dp[i+2]= min(dp[i+2], dp[i] +abs(h[i+2]-h[i]));
        }
    }
    cout << dp[n-1] << ed;
}

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

int main() {
  int n;cin>>n;
  int x=n*800;
  int y=n/15*200;
  int ans = x-y;
  // cout << (ans?"H":"D") << endl;
  cout << ans << endl;
}


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

int main() {
    string s;
    cin >> s;
    queue<char> q;
    rep(i,s.size()) q.push(s[i]);
    string pre = "*";
    int ans = 0;
    while (!q.empty()) {
        string t;
        t.push_back(q.front());
        q.pop();
        if (t == pre && !q.empty()) {
            t.push_back(q.front());
            q.pop();
        }
        if (t == pre && q.empty()) ans--;
        pre = t;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 644
/*
            ██        ██              ██        ██████
                    ██████                    ██    ██
        ████████    ██████    ████████      ████████
    ████        ██████████████        ████
  ██        ██████    ██    ██████        ██
██████████  ██████        ████████  ██████████
    ████████    ██████  ██████    ████████
        ████  ██    ██  ██    ██  ████
          ██  ██  ████  ████  ██  ██        ████████
          ██  ██    ██████    ██  ██          ██    ██
        ██      ██████  ██████      ██          ██████
  ██    ██          ██████          ██
        ██      ████████████████    ██
        ██    ██              ██      ██
          ██  ██    ██████    ██      ██      ████
      ██  ██  ██████      ██████        ██    ██  ██
    ████    ██                          ██    ██  ██████████
  ██  ██      ██            ██            ██  ██  ██
  ██  ██        ████      ██              ██  ██  ██
  ████            ████  ██        ██      ██████  ██████████
                ████████        ██        ████    ████
              ██    ████    ████          ████  ██  ██
              ██    ██████████            ████  ██  ██
                ██████████                  ██  ██  ██
        ██████  ██████████████████████████████████  ██
        ██  ████████  ██                    ██  ██  ████
        ██████████      ██████████████████████████    ██
          ██████        ██                  ██        ██████
                          ██                ██
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int h[n]; rep(i,n) cin>>h[i];
    int cnt=0;
    rep(q,110){
        rep(i,n){
            if(i+1<n&&h[i]>0&&h[i+1]<=0) cnt++;
            if(i==n-1&&h[i]>0) cnt++;
            h[i]--;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
    }
    println!("{}", if (A*B)%2==0{"Even"}else{"Odd"});
}

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

using namespace std;
constexpr long long int mod = 1000000007;
int main() {
    int a, b,c;
    cin >> a >> b>>c;
    if (b % a == 0 || c % a == 0 || b / a != c / a)cout << "OK";
    else cout << "NG";
}

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

string s;
vector<int> a(4);

int main()
{
	cin>>s;
	for(int i=0;i<4;i++) a[i]=s[i]-'0';
	
	for(int k=0;k<(1<<3);k++)
	{
		int ans=a[0];
		for(int i=0;i<3;i++) if(k>>i&1) ans+=a[i+1]; else ans-=a[i+1];
		if(ans==7)
		{
			string S="0-0-0-0=7";
			for(int i=0;i<4;i++) S[i*2]='0'+a[i];
			for(int i=0;i<3;i++) if(k>>i&1) S[i*2+1]='+';
			cout<<S;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    int c=0;
    REP(i,n){
        int h;
        cin>>h;
        if(h>=k)c++;
    }
    print(c);
}


Measured memory_bytes: 256
s = str(input().rstrip())
l=0
r=1
tmp =''
li = list()
while(r<=len(s)):
  if(s[l:r]!=tmp):
    li.append(s[l:r])
    tmp=s[l:r]
    l=r
    r+=1      
  else:
    r+=1

print(len(li))

Measured memory_bytes: 8312
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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

int main(){
    ll a, b, c; cin >> a >> b >> c;
    bool okay = false;
    if(4*a*b < (c-a-b)*(c-a-b)) okay = true;
    if(c < a+b) okay = false;
    cout << (okay ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for(int i=0; i<N; i++){
   cout << A.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N;cin>>N;ll N0=N;
    ll R=sqrt(N);
    vi v;
    FOR(i,2,R+2){
        while(N%i==0){
            N/=i;
            v.push_back(i);
        }
    }
    if(N>1)v.push_back(N);
    cout<<N0<<":";
    REP(i,v.size()){
        cout<<" "<<v[i];
    }
    cout<<"\n";
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define r(i,N) for(int i=0;i<N;i++)
int main(){
  int N,M,c=0;
  cin >> N;
  map<string,int> mp;
  string a[N];
  r(i,N)cin >> a[i];
  cin >> M;
  string b[M];
  r(i,M)cin >> b[i];
  r(i,N)mp[a[i]]++;
  r(i,M)mp[b[i]]--;
  r(i,N)c=max(c,mp[a[i]]);
  cout << c << endl;
}	

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


int main() {

    string s;
    cin >> s;
    int n = s.length();
    for (int i = n - 1; i; --i) {
        string tmp = s.substr(0,i);
        int m = tmp.length();
        if (m % 2 == 0) {
            if (tmp.substr(0,m/2) == tmp.substr(m/2)) {
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;


import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long x = in.nextLong();
        out.println(x / 500 * 1000 + x % 500 / 5 * 5);
    }


}



class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(rall(a));
    int c=0;
    ll memo;
    rep(i,m){
        if(c==0){
            a[0]/=2;
            memo=a[0];
            c++;
            
        }
        else{
            if(a[c]>=memo){
                a[c]/=2;
                c++;
            }
            else{
                sort(rall(a));
                c=1;
                a[0]/=2;
                memo=a[0];
            }
        }
        if(c==n){
                c--;
            }


        //a[c]/=2;
    }





    ll ans = 0;
    rep(i, n)
    {
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

const ll INF = 1e12;
struct Edge {
  int u, v;
  ll cap, flow;
  Edge() {}
  Edge(int u, int v, ll cap): u(u), v(v), cap(cap), flow(0) {}
};

struct Dinic {
  int N;
  vector<Edge> E;
  vector<vector<int>> g;
  vector<int> d, pt;
  
  //Everything is 0-based
  Dinic(int N): N(N), E(0), g(N), d(N), pt(N) {}

  void AddEdge(int u, int v, ll cap) {
    if (u != v) {
      E.emplace_back(Edge(u, v, cap));
      g[u].emplace_back(E.size() - 1);
      E.emplace_back(Edge(v, u, 0));
      g[v].emplace_back(E.size() - 1);
    }
  }

  bool BFS(int S, int T) {
    queue<int> q({S});
    fill(d.begin(), d.end(), N + 1);
    d[S] = 0;
    while(!q.empty()) {
      int u = q.front(); q.pop();
      if (u == T) break;
      for (int k: g[u]) {
        Edge &e = E[k];
        if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
          d[e.v] = d[e.u] + 1;
          q.emplace(e.v);
        }
      }
    }
    return d[T] != N + 1;
  }

  ll DFS(int u, int T, ll flow = -1) {
    if (u == T || flow == 0) return flow;
    for (int &i = pt[u]; i < g[u].size(); ++i) {
      Edge &e = E[g[u][i]];
      Edge &oe = E[g[u][i]^1];
      if (d[e.v] == d[e.u] + 1) {
        ll amt = e.cap - e.flow;
        if (flow != -1 && amt > flow) amt = flow;
        if (ll pushed = DFS(e.v, T, amt)) {
          e.flow += pushed;
          oe.flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }

  ll MaxFlow(int S, int T) {
    ll total = 0;
    while (BFS(S, T)) {
      fill(pt.begin(), pt.end(), 0);
      while (ll flow = DFS(S, T))
        total += flow;
    }
    return total;
  }
};


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n;cin>>n;
	ll a[n];For(i,0,n) cin>>a[i];

	Dinic D(n+2);
	For(i,0,n) For(j,i+1,n){
		if((j+1)%(i+1)==0){
			D.AddEdge(j,i,INF);
		}
	}
	ll s = n , t=n+1;
	For(i,0,n){
		if(a[i]==0) continue;
		if(a[i]<0){
			D.AddEdge(i,t,-1*a[i]);
		}else{
			D.AddEdge(s,i,a[i]);
		}
	}

	ll X = 0;
	For(i,0,n) if(a[i]>0) X+=a[i];
	cout<<X-D.MaxFlow(s,t)<<endl;










	
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int m, f, r;
	scanf("%d %d %d", &m, &f, &r);
	while( !(-1 == m && -1 == f && -1 == r) )
	{
		/*if(-1 == m)
			m = 0;
		if(-1 == f)
			f = 0;
		if(-1 == r)
			r = 0;*/

		if( -1 == m || -1 == f )
		{
			printf("F\n");
			scanf("%d %d %d", &m, &f, &r);
			continue;
		}

		if(-1 == m)
			m = 0;
		if(-1 == f)
			f = 0;
		if(-1 == r)
			r = 0;

		if( 80 <= m + f )
			printf("A\n");
		else if( 65 <= m + f )
			printf("B\n");
		else if( 50 <= m + f )
			printf("C\n");
		else if( 30 <= m + f && 50 <= r )
			printf("C\n");
		else if( 30 <= m + f )
			printf("D\n");
		else
			printf("F\n");

		scanf("%d %d %d", &m, &f, &r);
	}

	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

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

struct AAA
{
	int a, b, c, d;
};

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	rep(i, 0, h - 1)rep(j, 0, w - 1)cin >> a[i][j];
	int yHold = 0, xHold = 0;
	bool isHold = false;
	vector<AAA> vec;

	rep(i, 0, h - 1)
	{
		if (i % 2 == 0)
		{
			for (int j = 0; j <= w - 1; ++j)
			{
				if (isHold)
				{
					vec.push_back({ yHold + 1,xHold + 1,i + 1,j + 1 });
					++a[i][j];
				}
				if (a[i][j] % 2 == 1)
				{
					isHold = true;
					yHold = i;
					xHold = j;
				}
				else
				{
					isHold = false;
				}
			}
		}
		else
		{
			for (int j = w - 1; 0 <= j; --j)
			{
				if (isHold)
				{
					vec.push_back({ yHold + 1,xHold + 1,i + 1,j + 1 });
					++a[i][j];
				}
				if (a[i][j] % 2 == 1)
				{
					isHold = true;
					yHold = i;
					xHold = j;
				}
				else
				{
					isHold = false;
				}
			}
		}
	}
	cout << vec.size() << endl;
	for (auto x : vec)
	{
		cout << x.a << " " << x.b << " " << x.c << " " << x.d << endl;
	}
}



Measured memory_bytes: 5232
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    for s in range(S+1):
        if s-A[i-1] >= 0:
            dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-A[i-1]]) % MOD
        else:
            dp[i][s] = dp[i-1][s] * 2 % MOD
print(dp[N][S])



Measured memory_bytes: 132464
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a==1 && b>1)
{
cout<<"Alice";
return 0;
}
if(b==1 && a>1)
{
cout<<"Bob";
return 0;
}
if(a==b)
{
cout<<"Draw";
return 0;
}
if(a>b) cout<<"Alice";
else cout<<"Bob";
return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#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;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

ll a, b, c;

ll wyn;

int main()
{
	scanf("%lld%lld%lld", &a, &b, &c);
	wyn=b;
	ll lecz=a+b;
	wyn+=min(lecz+1, c);
	
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 100001
typedef long long ll;
int N, M, vis[MAX];
ll cz, cc, cn;
vector<int> adj[MAX];

bool dfs(int cur, int st){
	vis[cur] = st;
	bool ret = false;
	for(auto &next : adj[cur]){
		if(vis[next] != -1){
			if(vis[next] == vis[cur])	ret |= 1;
		}
		else{
			ret |= dfs(next, st ^ 1);
		}
	}
	return ret;
}

int main(){
	memset(vis, -1, sizeof(vis));
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 1; i <= N; i++){
		if(vis[i] == -1){
			if(adj[i].empty()){
				cz++;
				continue;
			}
			bool flag = dfs(i, 0);
			if(flag) cc++;
			else cn++;
		}
	}
	cout << cz * cz + 2 * cz * N - 2 * cz * cz + (cc + cn) * (cc + cn) + cn * cn << endl;
	return 0;
}

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

int main()
{
ll n ;
cin >> n ;
vector<ll> v(n);
rep(i, n){
  cin >> v[i];
}
rep(j,60){
  ll a=0,b=0;
  rep(i,n){
    if(((v[i])>>j)&1LL)a++;
    else b++;
  }
  ll c=a*b;
  c%=mo;
  ll d=(1LL<<j)%mo;
  ans+=(c*d);
  ans%=mo;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 2560
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

cnt = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tmp = 0
        for k in range(d):
            tmp += (x[i][k] - x[j][k]) ** 2
        dis = tmp ** (1 / 2)
        if dis.is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> llll;

const int Maxn = 100005;

map <ll, vector <ll> > A, B, C, D;
map <ll, set <llll> > Sa, Sb, Sc, Sd;
int n, a, b;
int X[Maxn], Y[Maxn];
int er[Maxn]; 
ll dist;
vector <int> Q;
ll res;

void Go(map <ll, vector <ll> > &A)
{
	for (map <ll, vector <ll> >::iterator it = A.begin(); it != A.end(); it++)
		sort(it->second.begin(), it->second.end());
}

ll Get(map <ll, vector <ll> > &A, ll ind, ll lef, ll rig)
{
	map <ll, vector <ll> >::iterator it = A.find(ind);
	if (it == A.end()) return 0;
	return upper_bound(it->second.begin(), it->second.end(), rig) - lower_bound(it->second.begin(), it->second.end(), lef);
}

ll Count(ll x, ll y)
{
	return   Get(A, x - y + dist, y - dist, y - 1) +
			 Get(B, x - y - dist, y + 1, y + dist) +
			 Get(C, x + y - dist, x - dist, x - 1) +
			 Get(D, x + y + dist, x + 1, x + dist);
}

void Insert(map <ll, set <llll> > &A, ll ind, ll lef, ll rig)
{
	map <ll, set <llll> >::iterator it = A.find(ind);
	if (it == A.end()) return;
	set <llll>::iterator sit = it->second.lower_bound(llll(lef, 0));
	while (sit != it->second.end() && sit->first <= rig) {
		if (!er[sit->second]) {
			er[sit->second] = true;
			Q.push_back(sit->second);
		}
		it->second.erase(sit++);
	}
}

void Insert(ll x, ll y)
{
	Insert(Sa, x - y + dist, y - dist, y - 1);
			 Insert(Sb, x - y - dist, y + 1, y + dist);
			 Insert(Sc, x + y - dist, x - dist, x - 1);
			 Insert(Sd, x + y + dist, x + 1, x + dist);
}

int main()
{
	scanf("%d %d %d", &n, &a, &b);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &X[i], &Y[i]);
		A[X[i] - Y[i]].push_back(Y[i]); Sa[X[i] - Y[i]].insert(llll(Y[i], i));
		B[X[i] - Y[i]].push_back(Y[i]); Sb[X[i] - Y[i]].insert(llll(Y[i], i));
		C[X[i] + Y[i]].push_back(X[i]); Sc[X[i] + Y[i]].insert(llll(X[i], i));
		D[X[i] + Y[i]].push_back(X[i]); Sd[X[i] + Y[i]].insert(llll(X[i], i));
	}
	Go(A); Go(B); Go(C); Go(D);
	dist = abs(X[a] - X[b]) + abs(Y[a] - Y[b]);
	Q.push_back(a); er[a] = true;
	Q.push_back(b); er[b] = true;
	for (int i = 0; i < Q.size(); i++) {
		res += Count(X[Q[i]], Y[Q[i]]);
		Insert(X[Q[i]], Y[Q[i]]);
	}
	cout << res / 2 << endl;
	return 0;
}

Measured memory_bytes: 97400
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  map<char, ll> max_pos;
  rep(i, N) max_pos[S[i]] = i;

  ll ans = -1;
  
  rep(i, N){
    vl alph(26, 0);
    ll cnt = 0;
    
    rep(j, i + 1){
      if(alph[S[j] - 'a'] == 1) continue;
      if(max_pos[S[j]] >= i + 1) alph[S[j] - 'a'] = 1;
    }

    rep(i, 26) cnt += alph[i];

    ans = max(ans, cnt);
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, M, K, ans = -1;
int rec[200000][3], cond[200000];//condition
int par[200000], rank[200000];
void init()
{
	for(int i = 0; i < N; i++)
	{
		par[i] = i;
		rank[i] = 0;
	}
}
int find(int a)
{
	return par[a] == a ? a : par[a] = find(par[a]);
}
void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if(x == y) return;	
	if(rank[x] < rank[y])
	{
		par[x] = y;
	}
	else
	{
		par[y] = x;
		if(rank[x] == rank[y]) rank[x]++;
	}
}
bool same(int x, int y)
{
	return find(x) == find(y);
}
int main()
{
	cin >> N >> M >> K;
	init();
	for(int i = 0; i < K; i++)
		for(int j = 0; j < 3; j++)
			cin >> rec[i][j];
	for(int i = 0; i < K; i++)
	{
		if(rec[i][0] == 1)
		{
			int temp = find(rec[i][1]), temp2 = find(rec[i][2]);
			if(cond[temp] && cond[temp2] && cond[temp] != cond[temp2])
			{
				ans = i;
				break;
			}
			unite(rec[i][1], rec[i][2]);
			if(cond[temp])
				cond[temp2] = cond[temp];
			else
				cond[temp] = cond[temp2];
		}
		if(rec[i][0] == 2)
		{
			int temp = find(rec[i][1]);
			if(cond[temp] && cond[temp] != rec[i][2])
			{
				ans = i;
				break;
			}
			cond[temp] = rec[i][2];
		}
	}
	
	ans++;
	cout << ans << endl;
}

Measured memory_bytes: 6548
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
using namespace std;

int N,W,wt[105],val[105],i,j;
ll dp[105][100005];

int main()
{
    cin>>N>>W;
    f(i,1,N+1)
    	cin>>wt[i]>>val[i];
    f(i,1,N+1)
    	f(j,1,W+1)
    	{
    		if(wt[i]>j)
    			dp[i][j]=dp[i-1][j];
    		else
    			dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
    	}
    /*f(i,0,N+1)
    {
    	f(j,0,W+1)
    		cout<<dp[i][j]<<' ';
    	cout<<endl;
    }*/
    cout<<dp[N][W];
}

Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 256
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

Measured memory_bytes: 147628
fn main() {
    ioset! { inp, buf }
    macro_rules! scan {
        ($($r:tt)*) => {
            input! { inp, $($r)* }
        }
    }
    macro_rules! print {
        ($($t:expr),*) => {
            write!(buf, $($t),*).unwrap();
        } 
    }
    scan! {
        n: usize,
        mut a: [usize; n],
    }
    let mut ans = 0;
    for i in 1..n {
        if a[i - 1] > a[i] {
            ans += a[i - 1]  - a[i];
            a[i] = a[i - 1];
        }
    }
    print!("{}\n", ans);
}

use std::io::{ stdout, BufWriter, Write };

#[macro_export]
macro_rules! ioset {
    ($inp:ident, $buf:ident) => {
        inset!($inp);
        outset!($buf);
    }
}

#[macro_export]
macro_rules! inset {
    (source = $s:expr, $iter:ident) => {
        let mut $iter = $s.split_whitespace();
    };
    ($iter:ident) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut $iter = s.split_whitespace();
    }
}

#[macro_export]
macro_rules! input {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt, $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, mut $var:ident : $t:tt, $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, ($var:expr) : $t:tt, $($r:tt)*) => {
        $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
}

#[macro_export]
macro_rules! read_value {

    // tuple
    ($iter:expr, ( $($t:tt), * )) => {
        ( $(read_value!($iter, $t)), * )
    };
    
    // array
    ($iter:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    
    // string
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    
    // any other
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[macro_export]
macro_rules! outset {
    ($buf:ident) => {
        let sout = stdout();
        let mut $buf = BufWriter::new(sout.lock());
    }
}

#[macro_export]
macro_rules! output {
    ($buf:expr, $($t:expr),*) => {
        write!($buf, $($t),*).unwrap();
    }
}

struct Chars<'a>(&'a Vec<char>);

impl<'a> std::fmt::Display for Chars<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        write!(f, "{}", self.0.iter().collect::<String>())
    }
}


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    ll ans = 0;
    if(n*2 <= m) {
        ans += n;
        m -= n*2;
        ans += m/4;
    }
    else {
        ans += m/2;
    }
    cout << ans << endl;
    return 0;
}

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

struct upd {
  int t, v;
  const bool operator<(const upd &u) { return t < u.t; }
} u[200005];
int uid = 0;

int main() {
  int n, t; cin >> n >> t;
  for (int i = 0; i < n; i++) {
    int l, r; cin >> l >> r;
    u[uid].t = l; u[uid].v = 1;
    uid++;
    u[uid].t = r; u[uid].v = -1;
    uid++;
  }
  sort(u, u + uid);
  int guid = 0, cus = 0, mcus = 0;
  for (int i = 0; i <= t; i++) {
    while (guid < uid && u[guid].t < i)
      cus += u[guid++].v;
    mcus = max(mcus, cus);
  }
  cout << mcus << endl;
}



Measured memory_bytes: 4688
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9

using namespace std;
inline int read()
{
		int x = 0, f = 1; char ch = getchar();
		while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
		while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
		return x * f;
}
const int N = 2e5 + 10;
const int zf = 26;

int n;
char s[N];

int f[N], nxt[N][zf], bef[zf];

int main()
{
    scanf("%s", s);
    n = strlen(s);
    rep(i, 0, n - 1) s[i] -= 'a';
    f[n] = 0;
    rep(i, 0, zf - 1) nxt[n][i] = -1;
    rep(i, 0, zf - 1) bef[i] = n;

    rrep(i, n - 1, 0)
    {
        memcpy(nxt[i], bef, sizeof bef);
        f[i] = N;
        rep(j, 0, zf - 1)
            f[i] = min(f[i], f[bef[j]] + 1);
        bef[s[i]] = i;
    }

    int ans = N;
    rep(j, 0, zf - 1)
        ans = min(ans, f[bef[j]] + 1);

    while (ans) 
        rep(i, 0, zf - 1)
            if (f[bef[i]] == ans - 1)
            {
                putchar(i + 'a');
                memcpy(bef, nxt[bef[i]], sizeof bef);
                ans --;
                break;
            }

    return 0;
}


Measured memory_bytes: 21504
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int a[51][51];
int tmp[51][51];
int ans[51][51];
int N;
void f(){
  memset(tmp,0,sizeof(tmp));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++)tmp[i][j]+=a[i][k]*a[k][j]%MOD;
    }
  }
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)a[i][j]=tmp[i][j]%MOD;
}
void g(){
  memset(tmp,0,sizeof(tmp));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++)tmp[i][j]+=a[i][k]*ans[k][j]%MOD;
    }
  }
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)ans[i][j]=tmp[i][j]%MOD;
}
//main
signed main(){
  int K;cin>>N>>K;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>a[i][j];
  memset(ans,0,sizeof(ans));
  for(int i=0;i<N;i++)ans[i][i]=1;
  while(K){
    if(K&1)g();
    f();
    K>>=1;
  }
  int fans=0;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)fans+=ans[i][j];
  cout<<fans%MOD<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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 namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

vector<ll> dm(1000001);
vector<ll> d(1000001);
vector<ll> m(1000001);

// return dm (s, e]
ll dm2(int s, int e) {
  return dm[e] - dm[s] - (d[s]*(m[e]-m[s]));
}

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

  int n; cin >> n;
  string s; cin >> s;

  rep(i, n) {
    dm[i+1] = dm[i];
    d[i+1] = d[i];
    m[i+1] = m[i];
    if (s[i] == 'D') {
      d[i+1] += 1;
    } else if (s[i] == 'M') {
      dm[i+1] += d[i];
      m[i+1] += 1;
    }
    //debug(d[i]);debug(m[i]);debugln(dm[i]);
  }

  int q; cin >> q;
  while(q--) {
    int k; cin >> k;
    ll ans = 0;
    for(int i=2; i<=n; i++) {
      if (s[i-1] == 'C') {
        int s = max(0, i-k);
        //debug(s);debug(i-1);debugln(dm2(s,i-1));
        ans += dm2(s, i-1);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 25500
# 各桁の総和を求める関数
def calcDigitSum(n):
    digitSum = 0
    digitSum += n % 10
    wari = n // 10

    while wari > 0:
        digitSum += wari % 10
        wari = wari // 10
    
    return digitSum

n = int(input())

if n % calcDigitSum(n) == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
countList = [0]*(10**6 + 1)
answer = 0

# Aにnがm個あるときcountList[n] = m
for i in A:
  countList[i] += 1

for j in range(10**6 + 1):
  # Aにjが含まれていれば、jの倍数をすべてcountListから除外
  # jの倍数pはjで割り切れるので除外可能
  # pの倍数qはjでも割り切れるのでjの時の処理によって除外される
  if countList[j] > 0:
    for k in range(2 * j, 10**6 + 1, j):
      countList[k] = 0
  # jが2個以上ある場合にはそれを正解としてカウントしない
  if countList[j] == 1:
      answer += 1

print(answer)

Measured memory_bytes: 32356
n = int(input())
nlst = [input() for _ in range(n)]
m = int(input())
mlst = [input() for _ in range(m)]

lst = []
lst.extend(nlst)
lst.extend(mlst)
lst = set(lst)

c = [nlst.count(i) - mlst.count(i) for i in lst]
c.append(0)
print(max(c))

Measured memory_bytes: 3064