akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    long long a;
  	long long b,c;
    scanf("%lld %lld.%lld",&a,&b,&c);
    cout << a * (b * 100 + c) / 100 << endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> r(n);
  rep(i, q){
    cin >> a[i];
    r[a[i]-1]++;
  }
  rep(i, n){
    if(k-q+r[i]>0){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)

int main(){
	int n;
	scanf("%d", &n);
	
	if(n>29) printf("Yes\n");
	else printf("No\n");

	//printf("%d\n", okane);

	
	return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    YesNo(n>=30);
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<endl
using namespace std;            typedef vector<int>  vi;
typedef long long ll;           typedef vector< ll>  vl;
typedef unsigned long long ull; typedef vector<ull>  vu;
typedef double dbl;             typedef vector<dbl>  vd;
typedef pair<int,int>pii;       typedef vector<pii>vpii; typedef map<int,int>mii;
typedef pair< ll, ll>pll;       typedef vector<pll>vpll; typedef map< ll, ll>mll;
typedef pair<dbl,dbl>pdd;       typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd;
typedef pair< ll,int>pli;       typedef vector<pli>vpli; typedef map< ll,int>mli;
typedef pair<dbl,int>pdi;       typedef vector<pdi>vpdi; typedef map<dbl,int>mdi;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
const int MD=1e9+7;
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(const ll a,const ll b){return a?gcd(b%a,a):b;}
ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:1;}
ll C2(const int n){return(ll)n*~-n/2;}
// (int) * (int) => (int)
// (int) / (int) => (int)

main(){cin.tie(0);ios::sync_with_stdio(false);
	ll n,m,d;
	cin>>n>>m>>d;
	printf("%.15f",(n-d<<!!d)*~-m/(double)(n*n));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  char c;
  cin>>c;
  if(c=='A')
     cout<<"T";
   if(c=='T')
     cout<<"A";
   if(c=='C')
     cout<<"G";
   if(c=='G')
     cout<<"C";
  return 0;
}
  

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static class DSU {
        int[] root;
        int[] rank;

        public DSU(int n) {
            root = new int[n];
            rank = new int[n];
            for(int i=0;i<n;i++) {
                root[i] = i;
            }
        }

        public int find(int x) {
            if(root[x] == x) {
                return x;
            }
            else {
                return find(root[x]);
            }
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if(x == y) {
                return;
            }
            if(rank[x] < rank[y]) {
                root[x] = y;
            }
            else {
                root[y] = x;
                if(rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), k = sc.nextInt();
        int[] count = new int[26];

        for(int i=0;i<n;i++) {
            char[] c = sc.nextLine().toCharArray();
            count[c[0] - 'A']++;
        }

        Arrays.sort(count);
        int ans;

        o:
            for(ans=0;true;ans++) {
                for(int i=25;26-i<=k;i--) {
                    if(count[i] <= 0) {
                        break o;
                    }
                    count[i]--;
                }
                Arrays.sort(count);
            }

        pw.println(ans);

        pw.close();
	}

}


Measured memory_bytes: 24276
# -*- coding: utf-8 -*-

def main():
    while 1:
        n = int(input())
        if n == 0:
            return 0
        s_l = []
        for _ in range(n):
            s_l.append(int(input()))
        ans = int((sum(s_l) - max(s_l) - min(s_l))/(n-2))
        print(ans)

if __name__ == "__main__":
    main()



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

int main(){
  int N;
  cin>>N;
  int L[2*N];
  for(int i=0;i<2*N;i++){
    cin>>L[i];
  }
  sort(L,L+2*N);
  int ans=0;
  for(int i=2*N-2;i>=0;i=i-2){
    ans+=L[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

int n, x, tot, ans;
bitset<4000005> bit;

int main() {
    scanf("%d", &n);
    bit.set(0);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &x);
        bit = bit | (bit << x);
        tot += x;
    }
    for (ans = (tot + 1) / 2; !bit[ans]; ans++);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2176
import numpy as np
c = np.zeros((3,3))
for i in range(3):
    c[i] = list(map(int,input().split()))
a = np.sum(c, axis=0)
b = np.sum(c, axis=1)
a_sub = [int(i/3) for i in a - a[0] if i%3 == 0]
b_sub = [int(i/3) for i in b - b[0] if i%3 == 0]
if (len(a_sub) != 3 or len(b_sub) != 3):
    print('No')
else:
    d = np.zeros((3,3),dtype=int)
    #print(a_sub,b_sub)
    for a_0 in range(int(c[0][0])+1):
        b_0 = c[0][0] - a_0
        for i in range(3):
            for j in range(3):
                d[i][j] = a_0 + a_sub[j] + b_0 + b_sub[i]
        if np.allclose(c, d):
            print('Yes')
            break
    else:
        print('No')

Measured memory_bytes: 12508
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val vv = listOfInt()
    val cc = listOfInt()
    var ans = 0

    for (i in 0 until n) {
        val diff = vv[i] - cc[i]
        if (diff > 0) ans += diff
    }
  
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}


Measured memory_bytes: 37864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
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;}
typedef pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA

int main(){
    string s,t; cin >> s >> t;
    string ans=" ";
    bool flag=0;
    rep(i,s.size()){
        if(s[i]=='?' || s[i]==t[0]){
            string ss=s;
            rep(j,t.size()){
                if(s[i+j]=='?'||s[i+j]==t[j]){
                    ss[i+j]=t[j];
                    if(j!=t.size()-1) continue;
                }
                else break;
                rep(i,ss.size()){
                    if(ss[i]=='?') ss[i]='a';
                }
                if(ans==" ") ans=ss;
                if(ans>ss) ans=ss;
                flag=1;
            }
        }
    }
    if(flag) cout << ans << endl;
    else cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=998244353;
const int N=410;
void Add(int &x,int y) { x+=y; if(x>=mod) x-=mod; }
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int f[2][N][N];
int a[N],b[N],n,s;
int inv[N],fac[N];
void getfac(int n) {
	fac[0]=1; for(int i=1;i<=n;++i) fac[i]=fac[i-1]*(ll)i%mod;
	inv[n]=Pow(fac[n],mod-2); for(int i=n;i>=1;--i) inv[i-1]=inv[i]*(ll)i%mod;
}
int main() {
	getfac(400);
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]),rd(b[i]),s+=a[i];
	int cur=0; f[cur][0][0]=mod-1;
	for(int i=1;i<=n;++i) {
		int nxt=cur^1; memcpy(f[nxt],f[cur],sizeof(f[cur]));
		for(int j=0;j<=400;++j)
			for(int k=0;k<=400;++k) if(f[cur][j][k]) {
				for(int x=0,t=1;x<b[i];++x,t=t*(ll)a[i]%mod)
					Add(f[nxt][j+a[i]][k+x],f[cur][j][k]*(ll)inv[x]%mod*t%mod*(ll)(mod-1)%mod);
			}
		cur=nxt;
	}
	int ans=0;
	for(int i=1;i<=400;++i) {
		int ii=Pow(i,mod-2);
		for(int j=0,t=ii;j<=400;++j,t=t*(ll)ii%mod) if(f[cur][i][j])
			Add(ans,f[cur][i][j]*(ll)t%mod*fac[j]%mod);
	}
	ans=ans*(ll)s%mod;
	printf("%d",ans);
	return 0;
}

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

// macro-----------------------------------------------------------------------------------------
#define rep(i, a, b) for (int i = a; i < b; i++)
#define int long long
const int inf = 100100100100000;
const int mod = 1000000007;

// general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr) {
    vector<int> ret = arr;
    rep(i, 1, arr.size()) { ret[i] += ret[i - 1]; }
    return ret;
}

// io_method-------------------------------------------------------------------------------------
int input() {
    int tmp;
    cin >> tmp;
    return tmp;
}
string raw_input() {
    string tmp;
    cin >> tmp;
    return tmp;
}
void print(int n) { cout << n << endl; }
void print(vector<int> arr) {
    cout << arr[0];
    rep(i, 1, arr.size()) cout << " " << arr[i];
    cout << endl;
}
void print(string s) { cout << s << endl; }

// main_method-----------------------------------------------------------------------------------

struct edge {
    int from, to, cost;
};
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n = input(), m = input();

    vector<edge> edges(m);
    rep(i, 0, m) edges[i] = {input() - 1, input() - 1, -input()};

    bool isnc = false;
    vector<int> dist(n, inf);
    dist[0] = 0;

    rep(i, 0, n) {
        rep(j, 0, m) {
            int frm = edges[j].from, to = edges[j].to, cost = edges[j].cost;
            if (dist[frm] != inf && dist[to] > dist[frm] + cost) {
                dist[to] = dist[frm] + cost;
                if (i == n - 1 && to == n - 1)
                    isnc = true;
            }
        }
    }

    if (isnc)
        print("inf");
    else
        print(-dist.back());
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <map>

using ll = long long;

int main()
{
  int N;
  std::vector<ll> A;

  std::cin >> N;

  A.resize(N);
  for (auto i = 0; i < N; ++i)
  {
    std::cin >> A[i];
  }

  std::map<ll, ll> cache;

  auto A2 = A;
  std::sort(A2.begin(), A2.end());

  static auto next_range = [](auto bgn, auto end, auto val) {
    auto tmp = bgn;
    while (tmp != end)
    {
      if (*tmp != val)
        return std::make_pair(bgn, tmp);
      ++tmp;
    }
    return std::make_pair(bgn, tmp);
  };

  auto pair = next_range(A2.begin(), A2.end(), A2[0]);
  auto bgn = pair.first;
  auto end = pair.second;

  while (1)
  {
    auto d = std::distance(bgn, end);

    cache.emplace(*bgn, d);

    if (end == A2.end())
      break;

    pair = next_range(end, A2.end(), *end);
    bgn = pair.first;
    end = pair.second;
  }

  ll total = 0;

  for (auto &&pair : cache)
  {
    auto d = pair.second;
    total += d * (d - 1) / 2;
  }

  for (auto i = 0; i < N; ++i)
  {
    int banned = A[i];
    auto it = cache.find(banned);
    std::cout << total - (it->second - 1) << std::endl;
  }
}

Measured memory_bytes: 12672
#include<iostream>
#include<queue>
#include<limits.h>
using namespace std;
int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };
static int map[1000][1000];
static int minPath[1000][1000];
typedef struct d Data;
struct d
{
	int x;
	int y;
	int count;
};
int main()
{
	int w, h;
	while (cin >> w >> h && w != 0 || h != 0)
	{
		for (int i = 0; i < 1000; i++)
		{
			for (int j = 0; j < 1000; j++)
			{
				map[i][j] = 0;
			}
		}

		for (int i = 0; i < h + (h - 1); i++)
		{
			for (int j = (i + 1) % 2; j < w + (w - 1); j+=2)
			{
				cin >> map[i][j];
			}
		}
		for (int i = 0; i < h + (h - 1); i++)
		{
			for (int j = 0; j < w + (w - 1); j++)
			{
				minPath[i][j] = INT_MAX;
			}
		}

		int ans = 0;
		queue<Data> q;
		Data first;
		first.x = 0;
		first.y = 0;
		first.count = 1;
		q.push(first);
		minPath[0][0] = 1;
		while (q.size() > 0)
		{
			Data data = q.front(); q.pop();
			if (data.x == w + (w - 1) - 1 && data.y == h + (h - 1) - 1)
			{
				ans = data.count;
				break;
			}

			for (int i = 0; i < 4; i++)
			{
				int nx = data.x + dx[i] * 2;
				int ny = data.y + dy[i] * 2;
				if (nx < 0 || nx >= w + (w - 1) || ny < 0 || ny >= h + (h - 1))continue;
				int px = data.x + dx[i];
				int py = data.y + dy[i];
				if (map[py][px] == 1)continue;
				if (data.count + 1 >=minPath[ny][nx])continue;
				Data d;
				d.x = nx;
				d.y = ny;
				d.count = data.count + 1;
				minPath[ny][nx] = d.count;
				q.push(d);
			}
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 7348
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <stack>
#ifndef WIN32
#define Auto "%lld"
#else
#define Auto "%I64d"
#endif
using namespace std;
typedef bool boolean;
#define smin(a, b) (a) = min((a), (b))

int n, m;
vector<int> *g;

inline void init() {
	scanf("%d%d", &n, &m);
	g = new vector<int>[(n + 1)];
	for(int i = 1, u, v; i <= m; i++) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
}

queue<int> que;
queue<int> step;
boolean vis[3][200005];
inline void bfs() {
	memset(vis, false, sizeof(vis));
	vis[0][1] = true;
	que.push(1);
	step.push(0);
	while(!que.empty()) {
		int e = que.front();
		int s = step.front();
		que.pop();
		step.pop();
		for(int i = 0; i < (signed)g[e].size(); i++) {
			int& eu = g[e][i];
			if(vis[s + 1][eu])	continue; 
			vis[s + 1][eu] = true;
			if(s != 1) {
				que.push(eu);
				step.push(s + 1);
			}
		}
	}
}

inline void solve() {
	puts((vis[2][n]) ? ("POSSIBLE") : ("IMPOSSIBLE"));
}

int main() {
	init();
	bfs();
	solve();
	return 0;
}

Measured memory_bytes: 13296
N,M = map(int,input().split(" "))
list = [0] * (M+1)
#print(list)

for i in range(N):
    A = input().split(" ")
    A = [int(i) for i in A]
    K = A[0]
    for j in range(K):
        list[A[j+1]] += 1
#print(list)
C = 0
for i in range(len(list)):
    if list[i] == N:
        C += 1
print(C)

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

class Program
{
    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split(' ');
        int n = int.Parse(inputs[0]);

        List<string> list = new List<string>();
        for (int i = 0; i < n; i++)
        {
            list.Add(Console.ReadLine());
        }
        list.Sort();
        List<string> a = list;

        Console.WriteLine(string.Join("", list));
    }
}

Measured memory_bytes: 11360
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main(){
  int N, K;
  int d_i, index_i, target_cnt=0;
  bool target_flag=true;
  int i, j;
  
  
  cin >> N >> K;
  vector<vector<int>> A(N, vector<int>(K, 0));

  for(i=0; i<K; i++){
    cin >> d_i;
    for(j=0; j<d_i; j++){
      cin >> index_i;
      A.at(index_i-1).at(i) = 1;
      // cout << "Increment A[" << index_i-1 << "][" << i << "]:" << A.at(index_i-1).at(i) << endl;
    }
  }


  for(i=0; i<N; i++, target_flag=true){
    for(j=0; j<K; j++){
      // cout << "A[" << i << "][" << j << "]:" << A.at(i).at(j) << endl;
      if(A.at(i).at(j) == 1){
        target_flag = false;
      }
    }
    if(target_flag){
      target_cnt++;
    }
  }
  
  cout << target_cnt << endl;

}

Measured memory_bytes: 3616
N, M = map(int, input().split())
all_dish = []

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]

print(len(prefer_dish))

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

using namespace std;

const int N = 3*100100;

int a[N];

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

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

	sort(a, a+3*n);
	long long sum = 0;
	for (int i = 3*n-2; i >= n; i-=2) {
		sum += a[i];
	}
	cout << sum << endl;
}

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

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

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

  int N, A, B;
  cin >> N >> A >> B;

  vector<int> x(N);
  for(int i = 0; i < N; i++) { cin >> x[i]; }

  // greedy
  ll sum = 0;
  for(int i = 0; i < N-1; i++) {
    ll dist = x[i+1] - x[i];
    ll walk = dist * A;
    ll tel  = B;
    if( tel < walk ) {
      sum += tel;
    } else {
      sum += walk;
    }
  }
  
  cout << sum << "\n";

  return 0;
}


Measured memory_bytes: 768
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] h = new int[n];
		for(i=0;i<n;i++) {
			h[i] = parseInt(sc.next());
		}
		sc.close();
		int mx=0;
		int cnt=0;
		for(i=0;i<n-1;i++) {
			if(h[i] >= h[i+1]) {
				cnt++;
			} else {
				if(cnt>mx) {
					mx=cnt;
				}
				cnt = 0;
			}
		}
		if(cnt>mx) {
			mx=cnt;
		}
		out.println(mx);
	}
}


Measured memory_bytes: 48444
using System;
 
class main{
  static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    int age = int.Parse(s[0]);
    int fee = int.Parse(s[1]);
    
    if (age < 6)
      fee = 0;
    else if(age <=12)
      fee /= 2;
    
    Console.WriteLine(fee);
  }
}

Measured memory_bytes: 27296
#include<stdio.h>
int main(){
  int xtw,ytw,rtw;
  scanf("%d %d",&xtw,&ytw);
  if(xtw<ytw){
    rtw=xtw;
    xtw=ytw;
    ytw=rtw;
  }
  while(ytw>0){
    rtw=xtw%ytw;
    xtw=ytw;
    ytw=rtw;
  }
  printf("%d\n",xtw);
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*五日目*/

	int n;cin >> n;
	vector<int> a(n-1);
	vector<int> b(n);
	for (int i = 0;i < n - 1;i++) {
		cin >> a[i];
		b[a[i] - 1]++;
	}
	for (int i = 0;i < n;i++)
		cout << b[i]<<"\n";
}

Measured memory_bytes: 4792
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n, m;
    cin >> n >> m;
    if (m % n == 0) {
        cout << m / n << endl;
        return 0;
    }
    for (ll i = m / n; i >= 1; --i) {
        if (m % i != 0) continue;
        ll rest = m - i * n;
        if (rest < 0) continue;
        if (rest % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3676
# editorial を参考にした
N = int(input())
water = [int(x) for x in input().split()]
rain = [0]*N
sum = 0

for i in water:
    sum += i


sa = 0
numofloop = 0
ite = 1
while (numofloop < (N - 1) / 2):
    sa += water[ite]
    ite += 2
    if (ite >= N):
        ite -= N
    numofloop += 1
sa *= 2
rain[0] = sum - sa

for k in range(1, N):
    rain[k] = 2*water[k-1]-rain[k-1]

print(' '.join(map(str, rain)))


Measured memory_bytes: 19096
n = int(input())
s = list(input())
m = 0
l = 0
for i in range(n):
    if s[i] == ")":
        m += 1
    else:
        m -= 1
    if l < m:
        l = m
s1 = ["("] * l
for i in s:
    if i == "(":
        l += 1
    else:
        l -= 1
s2 = [")"] * l
s = s1 + s + s2
print("".join(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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() {
    ll N;
    cin >> N;

    ll tmp = sqrt(2 * N);
    ll k;
    if (2 * N == tmp * (tmp - 1)) k = tmp;
    else if (2 * N == tmp * (tmp + 1)) k = tmp + 1;
    else {
        cout << "No" << endl;
        return 0;
    }

    ll a = 1;
    vvll ans(k);
    for(ll i = 0; i < k; i++) {
        for(ll j = i + 1; j < k; j++) {
            ans[i].push_back(a);
            ans[j].push_back(a);
            a++;
        }
    }

    cout << "Yes" << endl;
    cout << k << endl;
    rep(i, k) {
        cout << k-1;
        rep(j, k-1) {
            cout << " " << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3200
package main

import "fmt"

func main(){
	var n, k int
	fmt.Scanf("%d %d",&n,&k)
	a := make([]int,n)
	for i := range a {
		fmt.Scanf("%d",a[i])
	}
	var ans int
	if (n-1) % (k-1) == 0{
		ans = (n-1) / (k-1)
	} else {
		ans = (n-1) / (k-1) + 1
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5120
# coding : utf-8

import numpy as np

N = int(input())
D =input().split()
X = int(D[1])
D = int(D[0])

A = [int(input()) for i in range(N)]
suml = 0

for a in A:
    for i in range(D):
        if i*a + 1 <= D:
            suml += 1
        else:
            break
print(suml+X)


Measured memory_bytes: 21668
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int K, N, h[100000], MIN = intmax;
int main() {
	cin >> N >> K;
	for (int i = 0; i != N; ++i) {
		cin >> h[i];
	}
	sort(h, h + N);
	for (int i = K - 1; i != N; ++i) {
		MIN = min(MIN, h[i] - h[i - K + 1]);
	}
	cout << MIN << endl;
	return 0;
}

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

int main() {
  // 問題の種類と目標スコア
  int D, G;
  cin >> D >> G;

  // 問題数とコンプリートボーナス
  vector<int> p(D);
  vector<int> c(D);

  int ans = 0;
  for (int i = 0; i < D; i++) {
    cin >> p.at(i) >> c.at(i);
    // 全種類の全問を解答した場合を、解答数の上限とする
    ans += p.at(i);
  }

  // どの問題を全問解答するか、bit全検索で全パターンを検証する
  for (int tmp = 0; tmp < (1 << D); tmp++) {
    bitset<10> bs(tmp);
    int total_score = 0;
    int total_answers = 0;

    // 1が立っている問題について、スコアを加算する
    for (int i = 0; i < D; i++) {
      if (bs.test(i)) {
        int score = (i + 1) * 100;
        total_score += (score * p.at(i)) + c.at(i);
        total_answers += p.at(i);
      }
    }

    // 目標スコアを超えている場合、最小の問題数の実績を更新
    if (total_score >= G) {
      ans = min(ans, total_answers);

    // 目標スコアを超えていない場合、
    // 未着手の問題の内、1問あたりの配点が最も高い問題を
    // 一定件数解くことで、目標スコアを超えれるか確認する
    } else {
      // ターゲットの問題番号を算出
      int target = -1;
      for (int i = 0; i < D; i++) {
        if (bs.test(i) == 0) {
          target = i;
        }
      }

      // 目標スコアを満たしておらず、残っている解答が無い場合はスキップ
      if (target == -1) continue;

      // 目標スコアを超えた時点で探索終了
      int score = (target + 1) * 100;
      for (int j = 1; j <= p.at(target); j++) {
        int expected_score = total_score + (score * j);
        if (expected_score >= G) {
          total_answers += j;
          ans = min(ans, total_answers);
          break;
        }
      }
    }
  }

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


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = (Console.ReadLine().Split(' '));
            //string[] a = ("314159265358979323 846264338327950288 419716939 937510582".Split(' '));
            long[] b = new long[4];

            for(int i=0;i < a.Length ; i++)
            {
                b[i] = long.Parse(a[i]);
            }

            long al = b[2];
            long bl = b[3];
            long r = bl % al ;
            while(r!= 0)
            {
                bl = al;
                al = r;
                r = bl % al;
            }

            long basub = b[1] - b[0] + 1;
            long cdlcm = b[2] * b[3] / al;
            long cdiv = b[1] / b[2] - (b[0] - 1) / b[2];
            long ddiv = b[1] / b[3] - (b[0] - 1) / b[3];
            long cddiv =　b[1] / cdlcm - (b[0]-1) / cdlcm;
            Console.Write(basub - (cdiv + ddiv -cddiv));
        }
    }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, L;
int A[100100];

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

    std::cin >> N >> L;

    for(int i=1;i<=N;++i){
        std::cin >> A[i];
    }

    std::vector<int> v;

    for(int i=1;i<N;++i){
        if(A[i] + A[i + 1] >= L){
            v.emplace_back(i);
            for(int j=i+1;j<N;++j){
                v.emplace_back(j);
            }
            for(int j=i-1;j>=1;--j){
                v.emplace_back(j);
            }
            break;
        }
    }

    std::reverse(v.begin(), v.end());

    if(v.empty()){
        std::cout << "Impossible" << std::endl;
    }else{
        std::cout << "Possible" << std::endl;

        for(int i : v){
            std::cout << i << std::endl;
        }
    }
}


Measured memory_bytes: 1784
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
W = inputIL()

R = sum(W)
L = 0
MIN = INF

for i in W:
  R -= i
  L += i
  MIN = min(MIN,abs(R-L))
  
print(MIN)


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

int main() {
  int x;
  cin >> x;
  int fifth = x / 500;
  int fir = (x - fifth * 500) / 5;
  cout << 5 * fir + fifth * 1000 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int x;
    scan(x);

    vector<int> dp(200010, 0);
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[103] = 1;
    dp[104] = 1;
    dp[105] = 1;
    rep(now, x + 10) {
        if (now < 100)
            continue;
        for_(sell, 100, 106) {
            if (0 <= now - sell && dp[now - sell] == 1) {
                dp[now] = 1;
            }
        }
    }

    print(dp[x]);

    return 0;
}

Measured memory_bytes: 1024
if __name__ == "__main__":
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    tenbo = []
    for _ in range(n):
        tenbo.append(set())
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tenbo[a].add(b)
        tenbo[b].add(a)
    
    ans = 0

    for i in range(n):
        tmp = True
        for j in tenbo[i]:
            if h[i] <= h[j]:
                tmp = False
        if tmp:
            ans += 1
    print(ans)

Measured memory_bytes: 45264
#include<stdio.h>
int main()
{
    int n,h,w,i=0;
    scanf("%d %d %d",&h,&w,&n);
    int a[h][w];
    if(h>w)
    {
        do
        {
            i++;
        }while(h*i<n);
    }
    else
    {
        do
        {
            i++;
        }while(w*i<n);
    }
    printf("%d",i);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

int h, w;
char grid[1005][1005];

int solve() {
	int dp[h][w];
	fo(i, 0, h, 1) {
		fo(j, 0, w, 1) {
			dp[i][j] = 0;
		}
	}
	fo(i, 0, w, 1) {
		if (grid[0][i] == '#')	break;
		dp[0][i] = 1;
	}
	fo(i, 0, h, 1) {
		if (grid[i][0] == '#')	break;
		dp[i][0] = 1;
	}

	fo(i, 1, h - 1, 1) {
		fo(j, 1, w - 1, 1) {
			if (grid[i][j] == '#') continue;

			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= mod;

		}
	}

	return dp[h - 1][w - 1] % mod;

}

int32_t main() {

	cin >> h >> w;

	fo(i, 0, h, 1) {
		fo(j, 0, w, 1) {
			cin >> grid[i][j];
		}
	}

	cout << solve(); nl;
	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

Measured memory_bytes: 9088
import sys
L=[0 for i in range(5)]
for i in range(5):
  L[i]=int(input())
  
k=int(input())

for i in range(4):
  for j in range(i+1,5):
    if L[j]-L[i]>k:
      print(':(')
      sys.exit()
  
    if i==2 and j==3:
      print('Yay!')
  

Measured memory_bytes: 2940
from math import factorial

n,a,b = map(int,input().split())

mod = 10**9 + 7

def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1 #ビットシフト
  return ans

def ncr(n, r):
    x = 1
    y = 1
    for i in range(r):
        x *= (n-i)
        y *= (i+1)
        x %= mod
        y %= mod
    return (x * pow(y, 10**9+5)) % mod

ans = (pow(2,n) - ncr(n,a) - ncr(n,b) - 1) % mod

print(ans if ans >= 0 else ans + mod)


Measured memory_bytes: 38612
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int a[305];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    int ans=0;
    a[1]=3;
    a[2]=2;
    a[3]=1;
    ans=a[n]+a[m];
    if(n==1&&m==1)
        ans+=4;
    cout<<ans*100000<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long n,k,a,b,count=0;
  scanf("%lld%lld",&n,&k);
  if(k==0){
    printf("%lld\n",n*n);
    return 0;
  }
  for(b=k+1;b<=n;b++){
    a=n/b;
    count+=a*(b-k);
    if(n-a*b-k>=0)
      count+=n-a*b-k+1;
  }
  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long st[233333];
int num[233333],top;
bool vis[233333];
map<long long,long long> mp,que;
int pr[100010],pnum;
vector <int> des[233333];
ll times(ll a,ll b,ll mo)
{
	a%=mo;b%=mo;
	long long tmp=a*b-(long long)((long double)a/mo*b+1e-8)*mo;
	if (tmp<0) tmp+=mo;
	return tmp;
}
ll getmi(ll a,ll x,ll mo)
{
	ll ans=1;
	while (x)
	{
		if (x&1) ans=times(ans,a,mo);
		a=times(a,a,mo);
		x>>=1;
	}
	return ans;
}
ll gcd(ll a,ll b){if (!b) return a;return gcd(b,a%b);}
bool isprime(ll p)
{
	if ((p==2)||(p==3)||(p==5)) return true;
	if (p<=6) return false;
	if ((p&1)==0) return false;
	ll m=p-1,j=0;while ((m&1)==0) {m>>=1;j++;}
	for (int t=1;t<=10;t++)
	{
		ll b=rand()%(p-2)+2,v=getmi(b,m,p);
		if (v==1) continue;
		for (int i=1;i<=j;i++)
		{
			if (v==p-1) break;
			v=times(v,v,p);
		}
		if (v!=p-1) return false;
	}
	return true;
}
long long work(long long w)
{
	
	long long p=1,q=1;
	if (!isprime(w))
	{
		for (int i=1;((pr[i]*pr[i]<=w)&&(i<=pnum));i++)
		{
			int js=0;
			while (w%pr[i]==0)
			{
				w/=pr[i];
				js++;
			}
			js%=3;
			if (js==1) {p*=pr[i];if ((double)q*pr[i]*pr[i]>1.1e12) {p=q=0;break;}q=q*pr[i]*pr[i];}
			else if (js==2) {p=p*pr[i]*pr[i];if ((double)q*pr[i]>1.1e12) {p=q=0;break;}q=q*pr[i];}
		}
	}
	if (w!=1) {p*=w;if ((double)q*w*w>1.1e12) p=q=0;q=q*w*w;}
	if (p==0) return 0;
	mp[p]=q;mp[q]=p;//cout<<p<<' '<<q<<endl;
	return p;
}
pair<int,int> dfs(int s,int col=0)
{
	vis[s]=true;
	pair<int,int> p=make_pair((col==0)*num[s],(col==1)*num[s]);
	for (int k=0;k<des[s].size();k++) if (!vis[des[s][k]])
	{
		pair<int,int> q=dfs(des[s][k],col^1);
		p.first+=q.first;p.second+=q.second;
	}
	return p;
}
int main()
{
	//freopen("13.txt","r",stdin);
	pr[1]=2;pnum=1;
	for (int i=3;i<=100000;i+=2)
	{
		bool err=false;
		for (int j=2;j*j<=i;j++) if (i%j==0) {err=true;break;}
		if (!err) pr[++pnum]=i;
	}//cerr<<pnum<<endl;
	int n,ans=0,gg=0;scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		long long w;scanf("%lld",&w);
		w=work(w);
		if (w==0) {gg++;continue;}
		if (w==1) {ans=1;continue;}
		que[w]++;
	}
	ans+=gg;
	for (map<long long,long long>::iterator it=que.begin();it!=que.end();it++)
	{
		top++;
		st[top]=it->first;num[top]=it->second;
		it->second=top;
	}
	for (int i=1;i<=top;i++) if (que.count(mp[st[i]]))
	{
		des[i].push_back(que[mp[st[i]]]);
	}
	for (int i=1;i<=top;i++) if (!vis[i])
	{
		pair<int,int> p=dfs(i);//cout<<p.first<<' '<<p.second<<endl;
		ans+=max(p.first,p.second);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 23936
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC";
    else
    cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3612
#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;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

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

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

int main(){
    ll N,M,L;
    cin>>N>>M>>L;
    vector<vector<ll>> v(N,vector<ll>(N,INF));
    rep(i,M){
        ll A,B,C;
        cin>>A>>B>>C;
        v[A-1][B-1] = C;
        v[B-1][A-1] = C;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                chmin(v[i][j],v[i][k]+v[k][j]);
            }
        }
    }
    vector<vector<int>> g(N);
    rep(i,N){
        rep(j,N){
            if(v[i][j]<=L) g[i].push_back(j);
        }
    }
    int Q;
    cin>>Q;
    vector<vector<ll>> d(N,vector<ll>(N,-1));
    rep(i,N){
        d[i][i] = 0;
        queue<ll> bfs;
        bfs.push(i);
        while(!bfs.empty()){
            ll p = bfs.front();
            bfs.pop();
            for(auto x:g[p]){
                if(d[i][x]!=-1) continue;
                d[i][x] = d[i][p] + 1;
                bfs.push(x);
            }
        }
    }
    rep(i,Q){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        if(d[a][b]!=-1) cout<<d[a][b]-1<<endl;
        else cout<<-1<<endl;
    }
}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    LL ans = 1e18;
    for (int i = 0; i <= max(x, y); ++i) {
        ans = min(ans, 2LL * c * i + max(1LL * (x - i) * a, 0LL) + max(1LL * (y - i) * b, 0LL));
    }
    cout << ans << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int f[4][4];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    int a[4][4];
    FOR(i, 1, 3)
        FOR(j, 1, 3)
            cin >> a[i][j];
    cin >> n;
    FOR(i, 1, n)
    {
        int x;
        cin >> x;
        FOR(j, 1, 3)
            FOR(k, 1, 3)
                if(a[j][k] == x) f[j][k] = 1;
    }
    bool ok = 0;
    FOR(i, 1, 3)
    {
        bool fl = 1;
        FOR(j, 1, 3) if(f[i][j] == 0) {fl = 0; break;}
        if(fl) ok = 1;
    }
    FOR(i, 1, 3)
    {
        bool fl = 1;
        FOR(j, 1, 3) if(f[j][i] == 0) {fl = 0; break;}
        if(fl) ok = 1;
    }
    if(f[1][1] == f[2][2] && f[2][2] == f[3][3] && f[1][1] == 1) ok = 1;
    if(f[1][3] == f[2][2] && f[2][2] == f[3][1] && f[1][3] == 1) ok = 1;
    if(ok) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256