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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}


int main(){
    IOS;
    int a, b, k;

    cin >> a >> b >> k;

    vector<int> x;

    for (int i = 1; i <= min(a, b); i++){
        if (a % i == 0 && b % i == 0) x.push_back(i);
    }

    cout << x[x.size() - k] << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

vector<ll> prime;

void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
    repi(i,2,l){
        if(n%i==0){
        prime_factorize(i);prime_factorize(n/i);return;
        }
    }
    prime.pb(n);return;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  n*=2;
  prime_factorize(n);
  ll ans=10000000000000000;
  ll sqr=sqrt(n);
  repi(i,1,sqr+1){
    if(n%i!=0) continue;
    ll x,y;
    ll t=extGCD(i,n/i*(-1),x,y);
    if (abs(t)!=1) continue;
    while(y<=0 || x <=0){
      x+=n/i;
      y+=i;
    }
    ans=min(ans, min(abs(i*x),abs(n/i*y)));
    x=-x;
    y=-y;
    while(y<=0 || x <=0){
      x+=n/i;
      y+=i;
    }
    ans=min(ans, min(abs(i*x),abs(n/i*y)));
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int tc=1,n;cin>>n,n;tc++){
		vector<complex<int> > a(n);
		rep(i,n)
			cin>>real(a[i])>>imag(a[i]);
		int res=0;
		repi(i,2,n){
			complex<int> l1=a[i-1]-a[0];
			complex<int> l2=a[i]-a[0];
			res+=imag(conj(l1)*l2);
		}
		printf("%d %.1f\n",tc,0.5*abs(res));
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N, M = inpl()
    H = inpl()
    AB = [inpl() for _ in range(M)]
    ans = [True] * (N + 1)
    ans[0] = False
    for a, b in AB:
        if H[a - 1] < H[b - 1]:
            ans[a] = False
        elif H[a - 1] > H[b - 1]:
            ans[b] = False
        else:
            ans[a] = False
            ans[b] = False
    print(ans.count(True))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32004
/*SorooshH*/
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
const int MAX = 1e5;
const int MV = 1e5;
const int MOD = 1e9 + 7;
const int INF = 2e9;
ll MA = -INF , MI = INF;

ll n , h;
ll th[MAX+10] , wi[MAX+10];
ll curr;

ll ceil( ll n , ll m )
{
    if( n <= 0 )
        return 0;
    if( n%m == 0 )
        return n/m;
    else
        return (n/m)+1;
}

int32_t main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n >> h;

    for(int i=1 ; i<=n ; i++)
        cin >> wi[i] >> th[i] , MA = max( MA , wi[i] );

    sort( th+1 , th+n+1 ) , reverse( th+1 , th+n+1 );


    for(int i=0 ; i<=n ; i++)
        h-=th[i] , MI = min( MI , i + ceil( h , MA ) );
    cout << MI << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	if (K % 2) {
		long long int ans = 0;
		ans = (N / K)*(N / K)*(N / K);
		cout << ans << endl;
		return 0;
	}
	long long int ans = 0;
	ans = (N / K)*(N / K)*(N / K);
	long long int box = 0;
	for (int i = 1; i <= N; i++) {
		if (i%K == K / 2)box++;
	}
	ans += box * box*box;
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let add a s =
  IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s

let remove a s =
  match IntMap.find a s with
  | exception Not_found -> s
  | 1 -> IntMap.remove a s
  | n -> IntMap.add a (n - 1) s

let _ =
  Array.fold_left (fun (odd, acc, (q, q')) ->
    let (m, _) = IntMap.max_binding q in
    function
    | None ->
        Printf.printf "%d %d\n" m acc;
        (odd, acc, (q, q'))
    | Some (a, b) ->
        not odd,
        ( acc + b +
          if odd then
            abs (m - a)
          else
            let (m', _) = IntMap.min_binding q' in
            if a <= m then
              m - a
            else if m' <= a then
              a - m'
            else 0 ),
        if a < m then
          let q = add a q in
          if not odd
          then (q, q')
          else (remove (fst (IntMap.max_binding q)) q, add (fst (IntMap.max_binding q)) q')
        else
          let q' = add a q' in
          if odd
          then (q, q')
          else (add (fst (IntMap.min_binding q')) q), remove (fst (IntMap.min_binding q')) q')
  (false, 0, (IntMap.singleton min_int 1, IntMap.singleton max_int 1)) @@
  Scanf.scanf "%d " @@ fun q ->
    Array.init q @@ fun _ ->
      Scanf.scanf "%d " @@ function
        | 2 -> None
        | 1 -> Scanf.scanf "%d %d " @@ fun a b -> Some (a, b)


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

L = [None] * 3
for i in range(3):
    L[i] = [int(v) for v in input().split()]
    
rl = [L[0][0] - L[0][1], L[0][1] - L[0][2]]
hl = [L[0][0] - L[1][0], L[1][0] - L[2][0]]

for v in L:
    if [v[0] - v[1], v[1] - v[2]] != rl:
        print("No")
        sys.exit()
        
for i in range(3):
    if [L[0][i] - L[1][i], L[1][i] - L[2][i]] != hl:
        print("No")
        sys.exit()
        
print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[99];
int main(){
	a[0]=2;
	a[1]=1;
	rep(i,2,99)a[i]=a[i-1]+a[i-2];
	ll n;
	scanf("%lld",&n);
	printf("%lld",a[n]);
}

Measured memory_bytes: 128
s = gets.chomp.split("").map(&:to_s)
t = gets.chomp.split("").map(&:to_s)
min = s.length
s.each_cons(t.length) do |si|
  count = 0
  si.each_with_index do |sii,idx|
    count += 1 if sii != t[idx]
  end
  min = [min,count].min
end

puts min


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == '1') ans++;
    }

    cout << ans << endl;


    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
vl ans;

int main(){
  while(cin >> n){
    if(n == 0) break;
    vl s;
    for(ll i = 0;i < n;i++){
      ll x;
      cin >> x;
      s.push_back(x);
    }
    ll x = 0;
    x = accumulate(s.begin(),s.end(),0ll);
    x -= *max_element(s.begin(),s.end());
    x -= *min_element(s.begin(),s.end());
    ans.push_back(x/(s.size()-2));
  }
  for(ll x : ans){
    cout << x << endl;
  }

}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    if(N==2){
        cout<<-1<<endl;
        return 0;
    }
    vector<int> A(N),cnt(N),ans;
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]--;
        cnt[A[i]]++;
    }
    
    set<int> rem;
    set<pair<int,int>> SE;
    
    for(int i=0;i<N;i++){
        rem.insert(i);
        SE.insert({cnt[i],i});
    }
    
    while(rem.size()>=8){
        int a=(*SE.rbegin()).first,b=(*SE.rbegin()).second,c=*rem.begin();
        
        int pu=-1;
        
        if(a==rem.size()-1) pu=b;
        else if(ans.size()==0||A[ans.back()]!=c) pu=c;
        else{
            auto it=rem.begin();
            it++;
            pu=*it;
        }
        
        ans.push_back(pu);
        SE.erase({cnt[pu],pu});
        rem.erase(pu);
        
        SE.erase({cnt[A[pu]],A[pu]});
        cnt[A[pu]]--;
        SE.insert({cnt[A[pu]],A[pu]});
    }
    
    vector<int> S;
    for(auto a:rem) S.push_back(a);
    
    do{
        bool ok=true;
        for(int i=0;i+1<S.size();i++){
            if(A[S[i]]==S[i+1]) ok=false;
        }
        if(ok){
            for(int i=0;i<S.size();i++) ans.push_back(S[i]);
            break;
        }
        
    }while(next_permutation(all(S)));
    
    if(ans.size()!=N){
        cout<<-1<<endl;
        return 0;
    }
    
    for(int i=0;i<N;i++){
        cout<<ans[i]+1<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 11580
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define I64 ll
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> P;
typedef pair<P, int> PII;
typedef pair<LL, int> PIII;
const LL INF = 0x3f3f3f3f;
const int N = 5e5 + 10;
const int M = 1e5 + 10;
const LL mod = 998244353;
const double PI=acos(-1);
inline LL ab(LL x){return x < 0 ? -x : x;}
inline int mm(int x, int p){return x >= p ? x - p : x < 0 ? x + p : x;}

int v[N];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", &v[i]);
    sort(v + 1, v + n + 1);
    int ans = min(v[1], v[n] - v[1]), id = 1;
    for(int i = 2; i < n; ++i) if(min(v[i], v[n] - v[i]) > ans)    id = i, ans = min(v[i], v[n] - v[i]);
    printf("%d %d\n", v[n], v[id]);
    return 0;
}
/*
13
0 1 1 3 3 0 6 6 8 9 9 9
100
R 8 8
R 8 8
W 8
W 6
R 1 9
W 6
R
*/


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	ll K;
	cin >> K;
	cout << 50 << endl;
	vector<ll> a(50);
	for (int i = 0; i < 50; i++) {
		a[i] = i + K / 50 - K % 50;
		if (i < K % 50) a[i] += 51;
	}
	for (int i = 0; i < 50; i++) cout << a[i] << " ";
	cout << endl;
 }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n,k;
string s[2048];
int cntCh[27];
string ans;
bitset<1000048> can[2048];
Pair dp[2][1000048];

int main ()
{
	int i,j,cnt,ncnt,cur,minCh,minSt;
	n=getint();k=getint();
	for (i=1;i<=n;i++)
	{
		cin>>s[i];
		for (j=0;j<int(s[i].size());j++)
			cntCh[s[i][j]-'a'+1]++;
	}
	int fcnt=0;
	for (i=1;i<=26;i++)
		if (cntCh[i]) fcnt++;
	if (fcnt==1)
	{
		for (i=1;i<=26;i++)
			if (cntCh[i])
			{
				ans=string(k,'a'+i-1);
				cout<<ans<<endl;
				return 0;
			}
	}
	can[n+1][0]=1;
	for (i=n;i>=1;i--)
		can[i]=can[i+1]|(can[i+1]<<(int(s[i].size())));
	for (i=1;i<=n;i++)
		if (can[i+1][k-int(s[i].size())]) dp[0][++cnt]=mp(i,0);
	cur=0;
	for (i=1;i<=k;i++)
	{
		/*cnt=min(cnt,10000);*/ncnt=0;
		minCh=26;
		for (j=1;j<=cnt;j++)
			minCh=min(minCh,s[dp[cur][j].x][dp[cur][j].y]-'a'+1);
		ans+=string(1,'a'+minCh-1);
		minSt=INF;
		for (j=1;j<=cnt;j++)
			if (s[dp[cur][j].x][dp[cur][j].y]-'a'+1==minCh)
			{
				if (dp[cur][j].y==int(s[dp[cur][j].x].size())-1)
					minSt=min(minSt,dp[cur][j].x+1);
				else
					dp[cur^1][++ncnt]=mp(dp[cur][j].x,dp[cur][j].y+1);
			}
		for (j=minSt;j<=n;j++)
			if (k-i-int(s[j].size())>=0 && can[j+1][k-i-int(s[j].size())])
				dp[cur^1][++ncnt]=mp(j,0);
		cnt=ncnt;cur^=1;
	}
	cout<<ans<<endl;
	return 0;
}	

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{


    ll a,b,k;
    cin >> a >> b >> k;
    ll x = min(a, b);
    ll zz = 0;
    vector<ll> v;

    for(ll i = 1; i <= x; i++)
    {

        if(a%i == 0 && b%i == 0)
        {

            v.pb(i);
        }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    cout << v[k-1];
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >> k;
  char c = s[k-1];
  string ans = s;
  for(int i = 0; i < s.length(); i++) {
    ans[i] = ans[i] == c ? c : '*';
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <vector>

int main() {
  std::int_fast64_t n, k;
  std::cin >> n >> k;

  std::unordered_set<std::int_fast64_t> available_digits({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
  for (std::int_fast64_t i = 0; i < k; ++i) {
    std::int_fast64_t unavailable_digit;
    std::cin >> unavailable_digit;
    available_digits.erase(available_digits.find(unavailable_digit));
  }

  std::set<std::int_fast64_t> available_prices;
  for (const std::int_fast64_t digit1 : available_digits) {
    available_prices.insert(digit1);
  }
  for (const std::int_fast64_t digit1 : available_digits) {
    for (const std::int_fast64_t digit2 : available_digits) {
      available_prices.insert(digit1 * 10 + digit2);
    }
  }
  for (const std::int_fast64_t digit1 : available_digits) {
    for (const std::int_fast64_t digit2 : available_digits) {
      for (const std::int_fast64_t digit3 : available_digits) {
        available_prices.insert(digit1 * 100 + digit2 * 10 + digit3);
      }
    }
  }
  for (const std::int_fast64_t digit1 : available_digits) {
    for (const std::int_fast64_t digit2 : available_digits) {
      for (const std::int_fast64_t digit3 : available_digits) {
        for (const std::int_fast64_t digit4 : available_digits) {
          available_prices.insert(digit1 * 1000 + digit2 * 100 + digit3 * 10 + digit4);
        }
      }
    }
  }
  for (const std::int_fast64_t digit1 : available_digits) {
    for (const std::int_fast64_t digit2 : available_digits) {
      for (const std::int_fast64_t digit3 : available_digits) {
        for (const std::int_fast64_t digit4 : available_digits) {
          for (const std::int_fast64_t digit5 : available_digits) {
            available_prices.insert(digit1 * 10000 + digit2 * 1000 + digit3 * 100 + digit4 * 10 + digit5);
          }
        }
      }
    }
  }

  std::cout << *available_prices.lower_bound(n) << std::endl;
  return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
import java.util.Stack;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Stack<Character> q;
		String input = "";
		while (scanner.hasNext()) {
			input = scanner.nextLine();
			if (input.equals(".")) {
				break;
			}
			q = new Stack<Character>();
			boolean badFormat = false;
			char[] ch = input.toCharArray();
			int i = 0;
			while (i < ch.length) {
				char c = ch[i];
				switch (c) {
				case '(':
				case '[':
					q.push(c);
					break;
				case ')':
					if (!q.isEmpty()) {
						if (q.peek() == '(') {
							q.pop();
						} else {
							badFormat = true;
						}
					} else {
						badFormat = true;
					}
					break;
				case ']':
					if (!q.isEmpty()) {
						if (q.peek() == '[') {
							q.pop();
						} else {
							badFormat = true;
						}
					} else {
						badFormat = true;
					}
					break;
				default:
					break;
				}
				i++;
			}
			System.out.println((q.isEmpty() && !badFormat) ? "yes" : "no");
		}
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i = 0; i < n; i++){
  	cin >> a.at(i);
  }
  
  int maximum = 0;
  for(int i = 0; i < n; i++){
  	maximum = max(maximum, a.at(i));
  }
  for(int i = 0; i < n; i++){
  	if(maximum == a.at(i)){
    	a.at(i) /=2;
    	break;
    }
  }
  int sum = 0;
  for(int i = 0; i < n; i++){
  	sum += a.at(i);
  }
  cout << sum << endl;
}

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

int main(){
  int n; cin >> n;
  bool ok = false;
  int cnt = 0;
  rep(i, n){
    int x, y; cin >> x >> y;
    if(x == y) cnt++;
    else cnt = 0;
    if(cnt == 3) ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec(n);
  REP(i,n) cin >> vec[i];
  double ave = 0;
  REP(i,n) ave += vec[i];
  ave /= n;
  ave = round(ave);
  int ans = 0;
  REP(i,n) ans += abs(vec[i] - ave) * abs(vec[i] - ave);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll mod=1000000007ll;

vector<int>A;
int cnt[100005];

int main(){

	int N;
	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
		int Ai;
		scanf(" %d",&Ai);
		A.push_back(Ai);
		cnt[A[i]]++;
	}

	sort(A.begin(),A.end());

	if(N%2==1){
		int flag=0;
		if(cnt[0]!=1){flag=1;}
		for(i=2;i<N;i+=2){
			if(cnt[i]!=2){flag=1;}
		}
		if(flag==1){printf("0\n");}
		else{
			ll ans=1ll;
			for(i=2;i<N;i+=2){
				ans*=2ll;
				ans%=mod;
			}
			printf("%lld\n",ans);
		}
	}
	else{
		int flag=0;
		for(i=1;i<N;i+=2){
			if(cnt[i]!=2){flag=1;}
		}
		if(flag==1){printf("0\n");}
		else{
			ll ans=1ll;
			for(i=1;i<N;i+=2){
				ans*=2ll;
				ans%=mod;
			}
			printf("%lld\n",ans);
		}
	}

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int c0,c1,c2,c3;
  c0 = c1 = c2 = c3 = 0;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    if (s == "AC") c0++;
    else if (s == "WA") c1++;
    else if (s == "TLE") c2++;
    else if (s == "RE") c3++;
  }
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

vector<int> sieve(int n) {
    vector<bool> prime(n + 1,true);
    prime[0] = false;
    prime[1] = false;
    for (int i = 3; i * i <= n; i += 2) {
        if (prime[i]) {
            int j = 2;
            while (i * j <= n) {
                prime[i * j] = false;
                j ++;
            }
        }
    }
    vector<int> ans = {2};
    for (int i = 3; i < n + 1; i += 2) {
        if (prime[i]) ans.push_back(i);
    }
    return ans; 
}

using Pa = pair<ll,int>;
vector<pair<ll,int>> factorization(long long N,vector<int>& primes) {
    vector<pair<ll,int>> ret;
    for (int p:primes) {
        int power = 0;
        while (N%p == 0) {
            power ++;
            N /= p;
        }
        if (power > 0) ret.emplace_back(p,power);
    }
    if (N > 1) ret.emplace_back(N,1);
    return ret;
}

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

    ll N,p; cin >> N >> p;
    vector<int> primes = sieve(1000010);
    vector<Pa> fact = factorization(p,primes);
    ll ans = 1LL;
    for (Pa &p:fact) {
        rep(i,p.second/N) ans *= p.first;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define M 1000000007
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  string s;
  cin >> s;
  for (auto ss : s) {
    if (ss == ',') {
      cout << " ";
    } else {
      cout << ss;
    }
  }
  return 0;
}


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 200002

int n, m;
int x[MAXN];
int c[MAXN];
vector < pair<int, int> > g[MAXN];
vector < pair<int, int> > gr[MAXN];

void dfs(int v, int xx = 0) {
	x[v] = xx;
	c[v] = 1;
	for (const auto& t : g[v]) {
		int v2 = t.f;
		int cost = t.s;
		if (!c[v2]) dfs(v2, xx + cost);
		if (xx + cost != x[v2]) {
			puts("No");
			exit(0);
		}
	}
	for (const auto& t : gr[v]) {
		int v2 = t.f;
		int cost = t.s;
		if (!c[v2]) dfs(v2, xx - cost);
		if (xx - cost != x[v2]) {
			puts("No");
			exit(0);
		}
	}
}


int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int v1, v2, cost;
		scanf("%d%d%d", &v1, &v2, &cost);
		--v1, --v2;
		g[v1].pb({v2, cost});
		gr[v2].pb({v1, cost});
	}

	for (int i = 0; i < n; ++i) {
		if (c[i]) continue;
		dfs(i);
	}

	puts("Yes");

	return 0;
}


Measured memory_bytes: 23040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
  Cin(string, s);
  for(char c = 'a'; c <= 'z'; c ++) if(!Contains(s, c)){ Cout(c); return 0; }
  Cout("None");
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int length(string str) {
  int i = 0;
  while(str[i]) {
    i++;
  }
  return i;
}

int main()
{
  string S;
  cin >> S;
  
  int digit_S = length(S);
  
  long ans = 0;
  long num;
  
  for (int i = 0; i < pow(2, digit_S - 1);i++) {
    num = 0;
    for (int j = 0; j < digit_S; j++) {
      num *= 10;
      num += S[j]-'0';
      
      if ((i >> j) & 1) {
        ans += num;
        num = 0;
      }
    }
  ans += num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll Mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, Ans = 0;
    cin>>n>>k;
    ll x = 0, y = 0, p=0, q=n;
    for(int i=1 ; i<=k ; i++)
    {
        x+=p, y+=q;
        p++, q--;
    }
    ll ss1 = x, ss2=y;
    while(ss1 <= ss2)
    {
        Ans+=(ss2-ss1+1+Mod)%Mod;
        Ans%=Mod;
        ss1+=p, ss2+=q;
        p++, q--;
    }
    cout<<Ans<<"\n";
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N;
    int tmp;
    int fx = 0;
    cin >> N;
    tmp = N;

    int amari = 0;
    while( tmp > 0){
        amari = tmp % 10;
        fx = fx + amari;
        tmp = tmp / 10;
    }

    if(N % fx == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3612
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>l;

    int ara[n+9], sum[n+9];

    For(i,1,n)
    {
        ara[i] = l+i-1;
       // cout<<ara[i]<<" ";
    }

    sum[0] = 0;

    For(i,1,n)
    {
        sum[i] = sum[i-1]+ara[i];
    }

    int mn = INT_MAX;
    int res = 0;
    for(i = 1; i<=n; i++)
    {
        v = abs(sum[n] - (sum[n]-ara[i]));

       // cout<<v<<" ";
        if(v<mn)
        {
            mn = v;

            res = sum[n] - ara[i];
        }
    }

    cout<<res<<endl;

   // main();

    return 0;
}


Measured memory_bytes: 256
import sys
a = [int(l) for l in sys.stdin]    

remainder = 9
target = 0
total = 0
for x in a:
  tmp = x % 10
  if tmp == 0:
    continue
  if remainder >= tmp:
    remainder = tmp
    target = x

for x in a:
  if x == target:
    total += target
    target = 0
  else:
    tmp = x % 10
    if tmp == 0:
      total += x
    else:
      total += 10 * (x // 10 + 1)

print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    char b;
    io.read(b);
    switch(b){
        case 'A':
        cout << 'T';
        break;
        case 'C':
        cout << 'G';
        break;
        case 'G':
        cout << 'C';
        break;
        case 'T':
        cout << 'A';
        break;
    }
    return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long int lcm(long long int a,long long int b){
    long long int g = gcd(a,b);
    return (a/g)*b;
}


int main() {
    int l,r;
    cin >> l >> r;

    if((r-l)>=2019) pl(0)
    else {
        int ans = inf;
        for(int i=l;i<=r;i++) for(int j=i+1;j<=r;j++) chmin(ans,((i%2019)*(j%2019)%2019));
        pl(ans)
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

map<string, int> mmp;


int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        mmp[s]++;
        cnt = max(cnt, mmp[s]);
    }
    for (auto x : mmp) {
        if (x.second == cnt) {
            cout << x.first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25216
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	res := float64(0)
	for i := 1; i <= N; i++ {
		tmp := i
		if i >= K {
			res += (float64(1) / float64(N))
			continue
		}
		for j := 1; ; j++ {
			tmp = tmp * 2
			if tmp >= K {
				res += (float64(1) / float64(N)) * math.Pow(0.5, float64(j))
				break
			}
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

char a,b;
cin >> a >> b;

if(a=='H' and b=='H')cout << 'H' << endl;
else if(a=='H' and b=='D')cout << 'D' << endl;
else if(a=='D' and b=='H')cout << 'D' << endl;
else cout << 'H' << endl;



return 0;

}




Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int n, a[100000]; long long s[200000];

inline int reader()
{
	int ret = 0;

	while (true)
	{
		char c = getchar();

		if (c == '\n') break;

		ret = (ret << 1) + (ret << 3) + c - 48;
	}

	return ret;
}

long long sum(int l, int r)
{
	return s[r] - s[l];
}

int main()
{
	n = reader();

	for (int i = 0; i < n; i++) a[i] = reader();

	s[0] = 0; for (int i = 1; i < 2 * n; i++) s[i] = s[i - 1] + a[(i - 1) % n];

	long long ret = 0, sums = s[n];

	for (int i = 0; i < n; i++)
	{
		int posr1 = lower_bound(s, s + 2 * n + 1, s[i] + sums / 3) - s;
		int posr2 = lower_bound(s, s + 2 * n + 1, s[i] + sums * 2 / 3) - s;

		ret = max(ret, min({ sum(i, posr1), sum(posr1--, posr2), sum(posr2, i + n) }));
		ret = max(ret, min({ sum(i, posr1), sum(posr1, posr2), sum(posr2, i + n) }));
	}

	printf("%lld\n", ret);

	return 0;
}

Measured memory_bytes: 4640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    ll n,a,b;cin>>n>>a>>b;
    VI x(n);
    rep(i,n)cin>>x[i];
    ll ans=0;
    rep(i,n-1){
        ll d=x[i+1]-x[i];
        ans+=min(b,a*d);
    }
    cout<<ans<<endl;
}

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

string s;

int main(){
	cin>>s;
	if(s == "SUN"){
		cout<<7<<endl;
	}else if(s == "MON"){
		cout<<6<<endl;
	}else if(s == "TUE"){
		cout<<5<<endl;
	}else if(s == "WED"){
		cout<<4<<endl;
	}else if(s == "THU"){
		cout<<3<<endl;
	}else if(s == "FRI"){
		cout<<2<<endl;
	}else if(s == "SAT"){
		cout<<1<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int sum(VI& a, int& l, int& r) { return a[r] - (l == 0 ? 0 : a[l - 1]); }
int main() {
    init();

    VI h, w;
    unordered_map<int, ll> hma, wma;
    for (int n, m; cin >> n >> m && n; hma.clear(),wma.clear()) {
        h.assign(n, 0), w.assign(m, 0); cin >> h >> w;
        FOR(i, 1, n)h[i] += h[i - 1];
        FOR(i, 1, m)w[i] += w[i - 1];
        FOR(i, 0, n)FOR(j, i, n)++hma[sum(h, i, j)];
        FOR(i, 0, m)FOR(j, i, m)++wma[sum(w, i, j)];
        ll ans = 0;
        each(i, hma)ans += i.second * wma[i.first];
        cout << ans << "\n";
    }
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  map<int,int> m;
  m[0]++;
  for(int i = 0; i < N; i++) {
    int t;
    cin>>t;
    m[t]++;
  }
  int ans=INF;
  vector<int> q;
  int cnt = 1;
  for(auto x:m){
    if(x.second>=3||(x.first==0&&x.second>=2)||(x.first==12&&x.second>=2)){
      ans=0;
      break;
    }
    else {
      if(x.second==2){
        q.push_back(x.first);
        q.push_back(24-x.first);
      }
      if(x.second==1){
        if(cnt==1) q.push_back(x.first);
        if(cnt==0) q.push_back(24-x.first);
        cnt=1-cnt;
      }
      sort(q.begin(),q.end());
      for(int i = 0; i < (int)q.size()-1;i++){
        chmin(ans,q[i+1]-q[i]);
      }
      chmin(ans,24-*(q.end()-1));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    mod = 1_000_000_007
    n, k = map(int, input().split())
    arrs = [0] * (k + 1)
    for i in range(k, 0, -1):
        arrs[i] = pow(k // i, n, mod)
        for j in range(i * 2, k + 1, i):
            arrs[i] -= arrs[j]
    ans = 0
    for i in range(1, k + 1):
        ans = (ans + arrs[i] * i % mod) % mod
    print(ans)

main()

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

int main(){
    int n, l;
    int ans = 0;

    cin >> n >> l;

    if (-l <= 0){
        ans = n*(n+1)/2-1+(l-1)*(n-1);
    }
    else if(-l >= n){
        ans = (n-1)*n/2+(l-1)*(n-1);
    }
    else{
        ans = n*(n+1)/2+(l-1)*n;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int S;
    cin >> S;
    int h, m, s;
    h = S / 3600;
    S %= 3600;
    m = S / 60;
    s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3096
n = int(input())
Sn = [input() for i in range(n)]

res = []


for s in Sn:
    res = sorted(list(set(s) or set(res)))

result = ""
for r in res:
    tmp = 10000
    for s in Sn:
        tmp = min(tmp, s.count(r))
    result += r*tmp

print(result)


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

    N = int(input())
    A = list(map(int, input().split()))

    ok = 1
    for a in A:
        if a%2 == 0:
            if a % 3 != 0 and a % 5 != 0:
                ok = 0
                break
    if ok:
        print('APPROVED')
    else:
        print('DENIED')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def solve_sub(k, n, p, factorials, invs):
    """Number of patterns where any pair(s) of p pairs appear when n dices are rolled"""
    ret = 0
    fp, ik = factorials[p], invs[k - 1]
    for q in range(1, min(p, n // 2) + 1):
        # tmp1 = factorials[p + q - 1] * invs[q] * invs[p - 1] % MOD
        tmp1 = (fp * invs[q] % MOD) * invs[p - q] % MOD
        tmp2 = (factorials[k + n - 2 * q - 1] * invs[n - 2 * q] % MOD) * ik % MOD
        if q % 2 == 1:
            ret += tmp1 * tmp2
        else:
            ret -= tmp1 * tmp2
        ret %= MOD
    return ret


def solve(k, n):
    if k == 1:
        return [0]
    factorials, invs = prepare(k + n, MOD)
    all_patterns_odd = factorials[k + n - 1] * invs[n] * invs[k - 1] % MOD
    all_patterns_even0 = factorials[k + n - 2] * invs[n] * invs[k - 2] % MOD
    all_patterns_even1 = factorials[k + n - 3] * invs[n - 1] * invs[k - 2] % MOD
    buf = []

    for i in range(2, k + 2):
        pairs = i // 2 - max(0, i - k - 1)
        if i % 2 == 0:
            ans = all_patterns_even0 - solve_sub(k - 1, n, pairs - 1, factorials, invs)
            ans += all_patterns_even1 - solve_sub(k - 1, n - 1, pairs - 1, factorials, invs)
            ans %= MOD
        else:
            ans = (all_patterns_odd - solve_sub(k, n, pairs, factorials, invs)) % MOD
        buf.append(ans)

    return buf


MOD = 998244353
k, n = map(int, input().split())
ans = solve(k, n)
print('\n'.join(map(str, ans)))
print('\n'.join(map(str, ans[-2::-1])))


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

const int Nmax=200010;
//#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//#definr REP(i,n) FOR(i,0,n)
//#define dump(x) cout << #x << "=" << (x) << endl;
//#define debug(x) cout << #x << "=" << (x) << "(L" << _LINE_ << ")" << "" << _FILE_ << endl;
//ll a[Nmax];
//int* P = new int[N];

int main() {
	int N,M,X,n[101]={0};
	int A[100];
	cin >> N >> M >> X;
	for(int i=0;i < M;i++){
		cin >> A[i];
		n[A[i]] = 1;
	}
	int maxL=0,maxR=0;
	for(int i=X;i < N+1;i++) maxR += n[i];
	for(int i=0;i < X;i++) maxL += n[i];
	cout << min(maxR, maxL) << endl;
	
	return 0;
}

Measured memory_bytes: 256