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

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        long ans = 0;
        int count = 0;
        int min = 1000000000;
        for(int i = 0; i < n; i++){
            int a = Integer.parseInt(sc.next());
            if(a < 0){
                count++;
            }
            a = Math.abs(a);
            ans += a;
            if(a < min){
                min = a;
            }
        }
        
        if(count % 2 == 0){
            System.out.println(ans);
        }else{
            System.out.println(ans - (min*2));
        }
    }
}

Measured memory_bytes: 46264
S = list(input())

ans = "AC"
tmp = S[2:-1]

if S[0] != "A":
  ans = "WA"
else:
  S.remove("A")
  
count = 0
for item in tmp:
  if item == "C":
    count += 1
    
if count != 1:
  ans = "WA"
elif count == 1:
  S.remove("C")


if "".join(S).lower() != "".join(S):
  ans = "WA"

print(ans)

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

main(){
  int K,S;
  cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; ++x){ 
    for(int y = 0; y <= K; ++y){
      
      int z = S - x - y;
      if(0 <= z and z <= K){
        
        ans = ans + 1;
      
        
      } ;
    };
  };
  cout << ans << endl; 
  return 0; 
};

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int ddx[8]={0,0,-1,1,1,1,-1,-1};
int ddy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//int arr[SIZE]={};
int main(){
	int N,M;
	cin>>N>>M;
	vector<ll> x,y;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		x.pb(a);
	}
	for(int i=0;i<M;i++){
		int a;
		cin>>a;
		y.pb(a);
	}
	ll eks=0,yai=0;
	for(int i=0;i<N;i++){
		int k=i+1;
		eks=(eks+(2*k-N-1)*x[i])%MOD;
	}
	for(int i=0;i<M;i++){
		int k=i+1;
		yai=(yai+(2*k-M-1)*y[i])%MOD;
	}
	//cout<<eks<<" "<<yai<<endl;
	cout<<eks*yai%MOD<<endl;
	return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int x, a, b; cin >> x >> a >> b;
    if( abs( x - a ) < abs( x - b ) ) cout << 'A' << endl;
    else cout << 'B' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int n;
    cin >> n;
    const ll mod=1e9+7;

    ll ans=1;
    for(int i=1; i<=n; i++){
        ans = ans*i%mod;
    }
   cout << ans << endl;

}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//io
#define s(x) scanf(" %d",&x)
#define si(x) scanf(" %d",&x)
#define sll(x) scanf(" %lld",&x)
#define sf(x) scanf(" %lf",&x)
#define ss(x) scanf(" %s",x)
#define sl(x) scanf(" %[^\n]",x)
#define sc(x) scanf("%c",&x)
#define p(x) printf(x)
#define pi(x) printf("%d",x)
#define ps(x) printf("%s",x)
#define pll(x) printf("%lld",x)
#define pf(x) printf("%lf",x)
#define pc(x) printf("%c",x)
#define endl "\n"
#define pn() printf("\n")
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL)
//loops
#define F(x,n) for(int i=x;i<n;i++)
#define Fr(x,n,c) for(int i=x;i<n;i+=c)
#define R(x,n) for(int j=x;j<n;j++)
#define Rr(x,n,c) for(int j=x;j<n;j+=c)
#define V(x,n) for(int k=x;k<n;k++)
#define Vr(x,n,c) for(int k=x;k<n;k+=c)
//ds
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define test() int __T;scanf("%d",&__T);for(int __t=1;__t<=__T;__t++)
#define mem0(x) memset(x,0,sizeof(x))
#define memdp(x) memset(x,-1,sizeof(x))
#define mp(x,y) make_pair(x,y)
bool prime(int n) {
	if(n%2==0) return false;
	for(int i=3;i<=sqrt(n);i+=2)
	if(n%i==0) return false;
	return true;
}
#define int long long
int f(int x) {
	if(x==1) return 1;
	return 2*f(x/2)+1;
}
int32_t main() {
	int h;
	cin>>h;
	cout<<f(h);
	return 0;
}























Measured memory_bytes: 256
n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for i in range(m)]
p=list(map(int,input().split()))
cnt=0

for i in range(2**n):
    pattern=format(i,"b").zfill(n)
    point=0
    
    for j in range(m):
        swi=0
        for k in s[j]:
            if pattern[k-1]=="1":
              swi +=1
        if swi%2==p[j]:
          point +=1
    if point==m:
      cnt +=1
      
print(cnt)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  string s;
  int d;
  cin>>n>>s>>d;
  string t = s;
  REP(i,n) if(d>0 && s[i]=='0'){
    t[i] = '1';
    --d;
  }
  REP(i,n) if(d>0 && s[n-1-i]=='1'){
    t[n-1-i] = '0';
    --d;
  }
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>

using namespace std;

int main()
{
    int n ;
    cin>>n ;
    int tmp = n ;
    int ans = 0 ;
    while(tmp > 0)
    {
        ans += (tmp % 10) ;
        tmp /= 10 ;
    }
    if(n % ans == 0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0 ;
}


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

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  vector<vector<int>> dp(n + 1, vector<int>(3010));
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, n) {
    rep(j, t) {
      chmax(dp[i + 1][j], dp[i][j]);
      int nj = j + p[i].first;
      if(nj < t) chmax(dp[i + 1][nj], dp[i][j] + p[i].second);
    }
    chmax(ans, dp[i][t - 1] + p[i].second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 35712
#include <cstdio>
#include <cstdlib>//mallocにいる
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

//NILは行き場がなくなったものを全て連結する何かという認識で良い？
Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x!=NIL) {
        y = x;
        if(z->key<x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL) {
        root = z;
    }
    else {
        if(z->key<y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u==NIL) {
        return;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if(u==NIL) {
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, x;
    string com;

    cin >> n;

    for(int i=0; i<n; i++) {
        cin >> com;
        if(com=="insert") {
            cin >> x;
            insert(x);
        }
        else if(com=="print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 26696
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }

    public static void main(String args[]) {
        scanner = new Scanner(System.in);
           
        int n = scanner.nextInt();
        
        int[] a = new int[n];
        
        for(int i = 0; i < n; ++i) {
            a[i] = i + 1;
        }
        
        int m = scanner.nextInt();
        
        for(int i = 0; i < m; ++i) {
            int lh, rh;
            
            String[] arr = scanner.next().split(",", -1);
            
            lh = Integer.parseInt(arr[0]) - 1;
            rh = Integer.parseInt(arr[1]) - 1;
            
            a[lh] = a[lh] ^ a[rh];
            a[rh] = a[lh] ^ a[rh];
            a[lh] = a[lh] ^ a[rh];
        }
        
        for(int i = 0; i < n; ++i) {
            System.out.println(a[i]);
        }
    }
}


Measured memory_bytes: 25844
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
typedef vector<ll> lvec;typedef vector<double> dvec;typedef vector<string> svec;
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  char c;
  cin>>c;
  cout<<char(c+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll n;
    	cin>>n;
    	cout<<(n*(n-1))/2;
    }
}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int a,b;
  cin >> a >> b;
  int ans = -1;
  rep(i,100000){
    if(i*8/100==a && i*10/100==b){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
 
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void){
  int number[100010];
  int x;
  scanf("%d",&x);
  for(int i = 0;i < 100010;i++){
      number[i] = 1; 
      //printf("%d -- %d\n",i+ 1,number[i]);
  }
  //1 is prime flag
  for(int i = 1;i < 10010;i++){
      if(number[i] == 1){
          for(int j = 2;((i + 1) * j) < 100010;j++){
              number[((i + 1) * j) - 1] = 0;
          }
      }
      //printf("%d -- %d\n",i+ 1,number[i]);
  }
  for(int i = x - 1;i < 100010;i++){
      if(number[i] == 1){
          printf("%d",i + 1);
          break;
      }
  }
  return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




#define MOD 1000000007
//逆元で二項係数を計算(MODは素数)　前処理O(n),本計算O(1)
#define MAXN 100000
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}
long long P(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	return fact[n] * ifact[n - r] % MOD;
}



int n, k;
vector<int> edge[100000];



long long dfs(int u, int p){
	int s = edge[u].size();
	long long ret = 1;

	if (p == -1) {
		ret = P(k, s + 1);
		for (int v: edge[u]) {
			if (v == p)continue;
			ret *= dfs(v, u);
			ret %= MOD;
		}
	}
	else {
		ret = P(k - 2, s - 1);
		for (int v : edge[u]) {
			if (v == p)continue;
			ret *= dfs(v, u);
			ret %= MOD;
		}
	}
	return ret;
}


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

	init();
	cin >> n >> k;

	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}


	cout << dfs(0, -1) << endl;



	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N, M, A[100], B[100];
  int Score[100] = {};

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < M; i++) {
    int Hit = 0;
    for(int j = 0; j < N; j++) {
      cin >> B[j];
      if(A[i] == B[j]) {
        ++Hit;
        ++Score[j];
      }
    }
    Score[A[i] - 1] += N - Hit;
  }
  for(int i = 0; i < N; i++) {
    cout << Score[i] << endl;
  }
  return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
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;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;cin >> n;
    while(n>0){
	n-=1000;
    }
    cout << -n << endl;
    return 0;
}


Measured memory_bytes: 3636
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.r(n);
  var ans = a[0] / 2 | 0;
  a[0] -= ans * 2;
  for(var i = 1; i < n; i++){
    if(a[i-1] && a[i])ans++, a[i-1]--, a[i]--;
    var t = a[i] / 2 | 0;
    ans += t;
    a[i] -= t * 2;
  }
  return ans;
}

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

int main()
{
	int n,t=0;
	cin>>n;
	long long a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	while(1==1){
		for(int i=1;i<=n;i++){
			if (a[i]%2==1){
				cout<<t<<endl;
				return 0;
			}
			a[i]/=2;
		}
		t++;
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main(){
    let n : usize = input();
    let mut c : Vec<(usize, usize)> = Vec::new();
    for _ in 0..n{
        let a : usize = input();
        let b : usize = input();
        c.push((b, a));
    }
    c.sort();
    let mut sum : usize = 0;
    let mut f = true;
    for i in 0..n{
        sum += c[i].1;
        if sum > c[i].0{
            f = false;
            break;
        }
    }
    let ans = if f {"Yes"} else {"No"};
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 9412
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0, var;
    for(int i = 0; i < N; i++){
        cin >> var;
        if(i % 2 == 0 && var % 2 == 1) {
            ans ++;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;

bool read() {
    if (!(cin >> n))
        return false;

    return true;
}

void solve() {
    vector<int> a(26, INF);

    while (n --> 0) {
        string s;
        cin >> s;
        vector<int> b(26);

        for (auto c : s)
            ++b[c - 'a'];

        forn (i, 26)
            a[i] = min(a[i], b[i]);
    }

    forn (i, 26)
        forn (j, a[i])
            cout << char('a' + i);

    cout << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
	ll ch[9][9];
int main() {
	ll n;cin>>n;
	for(ll i=1;i<=n;i++){
		ll b=i%10;
		if(b==0){
			continue;
		}
		ll now=i;
		while(now/10!=0){
			now/=10;
		}
		b--;now--;
		ch[now][b]++;
	}
	ll ans=0;
	for(ll i=0;i<9;i++){
		for(ll j=0;j<9;j++){
			ans+=ch[i][j]*ch[j][i];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

typedef long long ll;
//typedef vector<int> vi;
typedef vector<ll> vll;

const ll MOD = 1000000007;

int main()
{
	int n, i, j, s;
	ll rn = 0, k, r, l, inv2;
	scanf("%d %lld", &n, &k);
	vll nums(n), minr(n), minl(n);
	for (i = 0; i < n; i++) {
		scanf("%lld ", &nums[i]);
	}
	for (i = 0; i < n; i++) {
		s = 0;
		for (j = i + 1; j < n; j++) {
			if (nums[i] > nums[j])
				s++;
		}
		minr[i] = s;
	}
	for (i = n - 1; i >= 0; i--) {
		s = 0;
		for (j = i - 1; j >= 0; j--) {
			if (nums[i] > nums[j])
				s++;
		}
		minl[i] = s;
	}
	inv2 = (MOD - (MOD / 2));
	for (i = 0; i < n; i++) {
		r = (minr[i] * ((((k * (k + 1)) % MOD) * inv2) % MOD)) % MOD;
		l = (minl[i] * (((((k - 1) * k) % MOD) * inv2) % MOD)) % MOD;
		rn = (rn + ((r + l) % MOD)) % MOD;
	}
	printf("%lld\n", rn);
	return 0;
}

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

int main(){
    int N;
    int s = 0;
    int l ,r;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> l >> r;
        if(!(r == l)){
        s = s + (r - l) + 1;
        }
        if(r == l){
            s++;
        }
    }
    
    cout << s << endl;

}

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

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

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

ll bpow(ll x,ll n,ll m=MD,ll r=1LL){for(;n>0;n>>=1,x=x*x%m) if(n&1) r=r*x%m; return r;}
ll nCk_mod(ll n, ll k, int mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret = 1, rt2 = 1;
	for(ll i=n-k+1; i<n+1; i++) ret = ( ret * i) % mod;
	for(ll i=1; i<k+1; i++) rt2 = ( rt2 * i) % mod;
	return ( ret * bpow( rt2, mod-2, mod)) % mod;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x, y;
	cin >>x >>y;
	bool ok=1;
	if((x+y)%3) ok=0;
	int a = (2*y -x)/3;
	int b = y - 2*a;
	if(a<0 || b<0 || !ok){puts("0"); return 0;}
	
	ll ans = nCk_mod(a+b, a);
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;


int main()
{
int k;
int a[100];
for(int i =0 ; i < 5 ; i++) cin >> a[i];
cin >> k;
sort(a,a+5);
if(a[4]- a[0] <= k) cout << "Yay!";
else cout << ":(";


}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] P = Enumerable.Repeat(0, n).Select(_ => long.Parse(Console.ReadLine()))
                                 .OrderByDescending(x => x).ToArray();
            long ans = P.First() / 2 + P.Skip(1).Sum();
            Console.WriteLine(ans);
        }

        static void ReadInt2(out int first, out int second)
        {
            var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            first = array[0];
            second = array[1];
        }
    }
}

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

int main(){
    ll a,b,c,ans=0;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        ans=1;
    }
    else if(a!=b&&b!=c&&c!=a){
        ans=3;
    }else ans=2;
    cout<<ans<<endl;

    return 0;
    }

Measured memory_bytes: 256
Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b, f, r, v = list(map(int, input().split()))
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '+' '.join(map(str, Residents[k][j])))
    if k == 3:
        break
    print('####################')

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

namespace AOJ0012
{
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                var values = line.Split(' ').Select(double.Parse).ToArray();
                var p1 = new Point(values[0], values[1]);
                var p2 = new Point(values[2], values[3]);
                var p3 = new Point(values[4], values[5]);
                var p = new Point(values[6], values[7]);

                Console.WriteLine(InTriangle(p1, p2, p3, p) ? "YES" : "NO");
            }
        }

        public static bool InTriangle(Point p1, Point p2, Point p3, Point p)
        {
            var v12 = new Vector(p1, p2);
            var v1P = new Vector(p1, p);
            var v23 = new Vector(p2, p3);
            var v2P = new Vector(p2, p);
            var v31 = new Vector(p3, p1);
            var v3P = new Vector(p3, p);
            var vc1 = v12.Cross(v1P);
            var vc2 = v23.Cross(v2P);
            var vc3 = v31.Cross(v3P);

            if ((vc1.Z > 0 && vc2.Z > 0 && vc3.Z > 0)
                || (vc1.Z < 0 && vc2.Z < 0 && vc3.Z < 0))
            {
                return true;
            }

            return false;
        }
    }

    public class Point
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }

        public Point(double x = 0, double y = 0, double z = 0)
        {
            X = x;
            Y = y;
            Z = z;
        }
    }

    public class Vector
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }

        public Vector(double x = 0, double y = 0, double z = 0)
        {
            X = x;
            Y = y;
            Z = z;
        }

        public Vector(Point p1, Point p2) : this(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z)
        {
        }

        public Vector Cross(Vector other)
        {
            var x = Y*other.Z - Z*other.Y;
            var y = Z*other.X - X*other.Z;
            var z = X*other.Y - Y*other.X;

            return new Vector(x, y, z);
        }
    }
}

Measured memory_bytes: 6012
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map> 
#include <queue>

using namespace std;
typedef long long ll;
ll N, M;

int main(){

    ll ans = 0;

    cin >> N >> M;

    map<ll, vector<ll > > v;

    for(ll i = 0; i < N; i++){
        ll tempA, tempB;
        cin >> tempA >> tempB;
        v[tempA].push_back(tempB);
    }

    priority_queue<ll > q;

    //M日分しかループは回さない
    //M日後から1日, 2日・・・i日前を考えていく
    for(ll i = 1; i <= M; i++){
        //i日前で候補があるか調べる
        for(ll j = 0; j < v[i].size(); j++){
            //atでキーに対応する値を返す
            q.push(v[i].at(j));
        }

        if(q.size() == 0){
            continue;
        }

        ans += q.top();
        q.pop();

    }

    cout << ans << endl;


}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main()
{
long long N,ans=1;scanf("%lld",&N);
vector<int> colo(3,0);vector<int> A(N);
for(int i=0;i<N;i++)
{
  scanf("%d",&A[i]);int a=0;
  for(int j=0,k=1;j<3;j++)if(colo[j]==A[i]){if(k==1){colo[j]++;k--;}a++;}
  ans=ans*a%MOD;
}
printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<stdio.h>
    #define N 10000
    int main(void)
    {
      int i,j,s_total,t_total,k=0;
      int S[N],T[N];
      scanf("%d",&s_total);
      for(i=0;i<s_total;i++){
        scanf("%d",&S[i]);
      }
      
      scanf("%d",&t_total);
      for(j=0;j<t_total;j++){
        scanf("%d",&T[j]);
      }
     for(j=0;j<t_total;j++){
      for(i=0;i<s_total;i++){  
          if(S[i]==T[j]){
        	k++;
        	break;
          }
        }
      }
      printf("%d\n",k);
      return 0;
    }
    
      



Measured memory_bytes: 2144
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


int n, s[1010][1010];
int main() {
	cin >> n;
	REP(i, n) {
		int x, y, X, Y; cin >> x >> y >> X >> Y;
		s[x][y]++;
		s[x][Y]--;
		s[X][y]--;
		s[X][Y]++;
	}
	for (int i = 0; i <= 1000; i++) {
		for (int j = 1; j <= 1000; j++)s[i][j] += s[i][j - 1];
	}
	for (int j = 0; j <= 1000; j++) {
		for (int i = 1; i <= 1000; i++)s[i][j] += s[i - 1][j];
	}
	int ans = 0;
	REP(i, 1001)REP(j, 1001)ans = max(ans, s[i][j]);
	cout << ans << endl;
}


Measured memory_bytes: 7060
#include <iostream>

using namespace std;

int main (void) {
    int N, A, B;
    cin >> N >> A >> B;

    int plan1 = A * N;
    int plan2 = B;
    if ( plan1 < plan2 )
        cout << plan1;
    else
        cout << plan2;
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
vector<ll> vec;
void commDiv(ll a,ll b) 
{ 
    // find gcd of a,b 
    ll n =__gcd(a, b); 
  
    // Count divisors of n. 
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        // if 'i' is factor of n 
        if (n%i==0) 
        { 
            // check if divisors are equal 
            if (n/i == i) 
                vec.push_back(i); 
            else
                {
                    vec.push_back(i);
                    if((n/i)>0)
                    vec.push_back(n/i);
                }
        } 
    } 
    //return result; 
} 

int main() {
    fast();
    ll a,b;
    cin>>a>>b;
    commDiv(a, b);
    vector<ll>::iterator it;
    ll count = 0;
    bool flag=1;
    //SieveOfEratosthenes();
   /* for(ll i=0;i<vec.size();i++)
    cout<<vec[i]<<" ";*/
    for(ll i=0;i<vec.size();i++)
    {
        flag=1;
        for (ll j= 2; j <= sqrt(vec[i]); j++) { 
  
        // If n is divisible by any number between 
        // 2 and n/2, it is not prime 
        if (vec[i]%j==0) { 
            flag = 0;        
            break; 
        } 
     } 
    if (flag==1) { 
        count++;
    } 
}
    if(a==1||b==1)
    cout<<1<<endl;
    else
    cout<<count<<endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S, T;
	bool check = false;
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		if (S == T) check = true;
		char x = S[S.size() - 1];
		S.erase(S.size() - 1, 1);
		S = x + S;
	}
	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
}



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

using namespace std;

#define rep(i,n) for(long long int i=0;i<n;i++)
#define rep1(i,n) for(long long int i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(long long int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(long long int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define pf printf
#define sf scanf
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define vci(v) for(long long int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(long long int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mp make_pair
#define fir first
#define sec second
#define clr(arr) memset((arr),0,sizeof(arr))

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vb;
typedef vector<vector<double>> vvd;
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
typedef pair<int,int> pii;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{0,0},{1,0},{1,1},{0,1},{-1,1},{0,-1},{-1,-1},{0,-1},{1,-1}};
const long double Pi=3.141592653589793238462643383279502884197;
const long double Napier=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T,typename U>                                                   
inline pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template<typename T> inline void Swap(T *x,T *y){ T tem=*x; *x=*y; *y=tem; }

inline long long int rem(long long int n,long long int m){
	if(!m) return 0;
	return (n<0?(n%m)+m:(n%m));
}
  
             
/*The main code follows below*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,n; ci(n>>a);
	if(n%500>a) lco("No");
	else lco("Yes");
	return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 5000 + 10;
typedef bitset<N> B;
B prefix[N] , suffix[N];
int n , K , a[N];

int main(){
  scanf("%d%d",&n,&K);
  int sum=0;
  rep(i,1,n+1) scanf("%d",a+i);
  rep(i,1,n+1) a[i]=min(a[i],K),sum+=a[i];
  prefix[0][0]=1;
  rep(i,1,n+1) {
    prefix[i]=prefix[i-1]|(prefix[i-1]<<a[i]);
  }
  suffix[n+1][0]=1;
  per(i,1,n+1) {
    suffix[i]=suffix[i+1]|(suffix[i+1]<<a[i]);
  }
  int ans=0;
  rep(i,1,n+1) {
    bool ok = true;
    // [K - a[i] , K)
    int cnt = 0;
    rep(j,K-a[i],K) cnt+=suffix[i+1][j];
    rep(j,0,K) {
      if(j) {
        if(K-a[i]-j>=0)
          cnt-=suffix[i+1][K-a[i]-j];
        cnt+=suffix[i+1][K-j];
      }
      if(prefix[i-1].test(j) && cnt){
        ok = false;
        break;
      }
    }
    ans += ok;
  }
  printf("%d\n",ans);
  return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    for(ll i = 0; i < n; i++) cin>>a[i];
    sort(all(a));
    ll count = 0;
    for(ll i = 0; i < n; i++)
    {
        for(ll j = i + 1; j < n; j++)
        {
            for(ll k = j + 1; k < n; k++)
            {
                set<ll>s;
                s.insert(a[i]);
                s.insert(a[j]);
                s.insert(a[k]);
                if(s.size() < 3)
                    continue;
                if(a[i] + a[j] > a[k])
                    count++;
                
            }
        }
    }
    cout<<count;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <cstdio>

using namespace std;

int a[400];
int b[400];
long long sum[401][401];
long long dp[401][401];

int main() {
    int n, c, m = 1000000007, i, j, k;
    
    scanf("%d %d", &n, &c);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0; i < n; i++) scanf("%d", &b[i]);
    
    for (i = 0; i <= 400; i++) {
        sum[i][0] = 1;
        for (j = 1; j <= 400; j++) sum[i][j] = sum[i][j - 1] * i % m;
    }
    
    for (i = 1; i <= 400; i++) {
        for (j = 0; j <= 400; j++) {
            sum[i][j] += sum[i - 1][j];
            if (sum[i][j] >= m) sum[i][j] -= m;
        }
    }
    
    dp[0][0] = 1;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j <= c; j++) {
            if (dp[i][j] == 0) continue;
            
            for (k = 0; k <= c - j; k++) {
                dp[i + 1][j + k] += dp[i][j] * ((sum[b[i]][k] - sum[a[i] - 1][k] + m) % m) % m;
                if (dp[i + 1][j + k] >= m) dp[i + 1][j + k] -= m;
            }
        }
    }
    
    printf("%lld\n", dp[n][c]);
    
    return 0;
}


Measured memory_bytes: 2688
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_A = max(A)
A.sort()

if(max_A < K):
    print("IMPOSSIBLE")
else:
    num = 10**10
    for i in range(N-1):
        if(min(num, abs(A[i]-A[i+1]))):
            num = min(num, abs(A[i]-A[i+1]))

    for i in range(N):
        if(A[i] < K):
            continue
        if((K-A[i])%num == 0):
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 14224
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    if (q * 2 < h) h = q * 2;
    if (h * 2 < s) s = h * 2;
    if (s * 2 < d) d = s * 2;
    LL ans = 0;
    LL cnt;
    cnt = n / 2;
    ans = cnt * d;
    //cout << cnt << "," << ans << endl;
    n -= 2 * cnt;
    ans += n * s;
    //cout << cnt << "," << ans << endl;
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> obs(H,vector<int>(W));
  
  for(int i=0;i<H;++i){
    string tmp;
    cin >> tmp;
    for(int j=0;j<W;++j){
      obs[i][j] = (tmp[j]=='#' ? 1 :0); 
    }
  }

  vector<vector<int>> L(H,vector<int>(W));
  vector<vector<int>> R(H,vector<int>(W));
  vector<vector<int>> T(H,vector<int>(W));
  vector<vector<int>> B(H,vector<int>(W));
  
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(j==0){
        if(obs[i][j]==1){
          L[i][j] = 0;
        }else{
          L[i][j] = 1;
        }
      }else{
        if(obs[i][j]==1){
          L[i][j] = 0;
        }else{
          L[i][j] = L[i][j-1] + 1;
        }
      }
    }
  }
  
  for(int i=0;i<H;++i){
    for(int j=W-1;j>=0;--j){
      if(j==W-1){
        if(obs[i][j]==1){
          R[i][j] = 0;
        }else{
          R[i][j] = 1;
        }
      }else{
        if(obs[i][j]==1){
          R[i][j] = 0;
        }else{
          R[i][j] = R[i][j+1] + 1;
        }
      }
    }
  }
  
  for(int i=0;i<W;++i){
    for(int j=0;j<H;++j){
      if(j==0){
        if(obs[j][i]==1){
          T[j][i] = 0;
        }else{
          T[j][i] = 1;
        }
      }else{
        if(obs[j][i]==1){
          T[j][i] = 0;
        }else{
          T[j][i] = T[j-1][i] + 1;
        }
      }
    }
  }
  
  for(int i=0;i<W;++i){
    for(int j=H-1;j>=0;--j){
      if(j==H-1){
        if(obs[j][i]==1){
          B[j][i] = 0;
        }else{
          B[j][i] = 1;
        }
      }else{
        if(obs[j][i]==1){
          B[j][i] = 0;
        }else{
          B[j][i] = B[j+1][i] + 1;
        }
      }
    }
  }
  
  int ans = 0;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(obs[i][j]==0){
        int tmp = L[i][j]+R[i][j]+T[i][j]+B[i][j]-3;
        if(tmp > ans){
          ans = tmp;
        }
      }
    }
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 78720
#include<bits/stdc++.h>
#define H 1<<17
using namespace std;
int N,M,p[H],y[H],i;
vector<int>v[H];
int main(){
  scanf("%d%d",&N,&M);
  for(i=0;i<M;i++)scanf("%d%d",p+i,y+i),v[--p[i]].push_back(y[i]);
  for(i=0;i<N;i++)sort(v[i].begin(),v[i].end());
  for(i=0;i<M;i++)printf("%06d%06d\n",p[i]+1,lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin()+1);
  return 0;
}


Measured memory_bytes: 8704
import math
import collections
import fractions
import itertools
 
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    c = collections.Counter(a)
    box = []
    for i in c:
        if c[i] >= 2:
            for _ in range(c[i]//2):
                box.append(i)
    if len(box) < 2:
        print(0)
    else:
        box.sort(reverse=True)
        print(box[0]*box[1])
    return 0
 
if __name__ == "__main__":
    solve()

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

int	main() {
	int N, M;
	cin >>N >>M;
	vector<int> a(M);
	vector<vector<int>> c(M, vector<int> (0));
	vector<int> cb(M, 0);
	for (int i=0; i<M; i++) {
		int b;
		cin >>a.at(i) >>b;
		for (int j=0; j<b; j++) {
			int C;
			cin >>C;
			c.at(i).push_back(C);
			cb.at(i) = (cb.at(i) | (0x1<<(C-1)));
		}
	}
	int CostN=pow(2, N);
	vector<int> Cost(CostN, 100000001);
	Cost.at(0)=0;
	for (int i=0; i<M; i++) {
		for (int j=CostN-1; j>=0; j--) {
			int T=j|cb.at(i);
			Cost.at(T)=min(Cost.at(T), Cost.at(j)+a.at(i));
		}
	}
	if (100000001<=Cost.back())
		cout <<-1 <<endl;
	else
		cout <<Cost.back() <<endl;
	return 0;
};


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    string S;
    cin >> N >> S;

    string P = S.substr(0, N), Q = S.substr(N, N);

    map<pair<string, string>, ll> cnt;
    Rep (mask, 1<<N) {
        string a, b;
        Rep (i, N) {
            if (mask & (1 << i)) {
                a.push_back(Q[i]);
            } else {
                b.push_back(Q[i]);
            }
        }
        cnt[{a, b}]++;
    }

    ll ans = 0;
    Rep (mask, 1 << N) {
        string a, b;
        Rep (i, N) {
            if (mask & (1 << i)) {
                a.push_back(P[i]);
            } else {
                b.push_back(P[i]);
            }
        }
        reverse(b.begin(), b.end());
        reverse(a.begin(), a.end());
        ans += cnt[{b, a}];
    }

    cout << ans << "\n";
}

Measured memory_bytes: 87040
#include<iostream>
#include<algorithm>

using namespace std;

void Solution()
{
    int a[3];
    
    while(cin>>a[0]>>a[1]>>a[2])
    {
        sort(a, a + 3);
       
        cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    }
}

int main()
{
    Solution();
}

Measured memory_bytes: 1172
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
bool cmp(string a,string b)
{
    return a<b;
}
int n,m;
string s[105];
int main()
{
    cin>>n>>m;
    for (int i=1;i<=n;i++)
       cin>>s[i];
    sort(s,s+n+1,cmp);
    for (int i=1;i<=n;i++)
       cout<<s[i];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int frog_1(int arr[],int n){
    int dp[n+1];
    dp[1]=0;

    for(int i=2;i<=n;i++){
        int op1 = abs(arr[i]-arr[i-1]) + dp[i-1];
        int op2;
        if(i==2){
            op2 = INT_MAX;
        }
        else{
            op2 = abs(arr[i]-arr[i-2]) + dp[i-2];
        }
        dp[i] = min(op1,op2);
    }
    return dp[n];
}

int main() {
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    
    cout<<frog_1(arr,n);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long x,y,z;
	cin>>x;
	if(x>=1&&x<=pow(10,9))
	{
		cin>>y;
		if(y>=1&&y<=pow(10,9))
		{
			if(x<=y)cout<<"0"<<endl;
			else {z=x-y;
			cout<<z<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,x;
    
    cin>>s1>>s2>>s3>>s4>>s5>>s6>>s7>>s8>>s9>>s10;
    x=s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
    cout <<x<<endl;
    
    return 0;
}

Measured memory_bytes: 1164