akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();

int main()
{int N, K, a, b, tmp, ans;
 cin >> N >> K;
 int C[N];
 rep(i, N){
   cin >> C[i];
 }
 sort(C, C+N);
 ans = INF;
rep(i, N-K+1){
  a = C[i];
  b = C[i+K-1];
  tmp = b - a + min(abs(a), abs(b));
  ans = min(ans, tmp);
 }
 cout << ans << endl;
 
 
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A1, B1 = A[:], B[:]
ans1 = 0
for i in range(N):
    if A1[i] >= B1[i]:
        ans1 += B1[i]
    else:
        ans1 += A1[i] + min(A1[i + 1], B1[i] - A1[i])
        A1[i + 1] = max(0, A1[i + 1] - (B1[i] - A1[i]))

A2, B2 = A[:][::-1], B[:][::-1]
ans2 = 0
for i in range(N):
    if A2[i] >= B2[i]:
        ans2 += B2[i]
    else:
        ans2 += A2[i] + min(A2[i + 1], B2[i] - A2[i])
        A2[i + 1] = max(0, A2[i + 1] - (B2[i] - A2[i]))

print(max(ans1, ans2))


Measured memory_bytes: 22136
#include <stdio.h>

int main(){
    int n, price, i, min, max;
    scanf("%d",&n);

    for(i=0; i<n; i++){
        scanf("%d",&price);
        if(i==0) min = price;
        else{
            if(i==1) max = price - min;
            if(min > price) min = price;
            else if(max < price - min) max = price - min;
        }
    }

    printf("%d\n", max);
    return 0;
}



Measured memory_bytes: 1988
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct point{
	int x,y,z;
	point(int x,int y,int z):x(x),y(y),z(z){}
	bool operator<(const point& other) const {
		if(x==other.x){
			if(y==other.y){
				return z<other.z;
			}
			return y<other.y;
		}
		return x<other.x;
	}
};

int main(){
	int n,h;
	while(cin>>n>>h,n||h){
		vector<point> v;
		REP(i,h){
			string c;
			cin>>c;
			int ab[2];
			cin>>ab[0]>>ab[1];
			int x=-1,y=-1,z=-1;
			REP(j,2){
				switch(c[j]){
				case 'x':x=ab[j];break;
				case 'y':y=ab[j];break;
				case 'z':z=ab[j];break;
				}
			}
			v.push_back(point(x,y,z));
		}
		int ans=n*n*n;
		REP(i,h){
			set<point> s;
			int minus=n;
			REP(j,i){
				int x=v[i].x,y=v[i].y,z=v[i].z;
				if(x==-1)x=v[j].x;else if(v[j].x!=-1&&x!=v[j].x)continue;
				if(y==-1)y=v[j].y;else if(v[j].y!=-1&&y!=v[j].y)continue;
				if(z==-1)z=v[j].z;else if(v[j].z!=-1&&z!=v[j].z)continue;
				point p(x,y,z);
				if(!EXIST(s,p)){
					minus--;
				}
				s.insert(p);
			}
			ans-=minus;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int a,b,c;
  std::vector<int> v;
  scanf("%d %d %d\n",&a,&b,&c);
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  std::sort(v.begin(),v.end());
  printf("%d\n",v[2]*10+v[1]+v[0] );
  return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;
 


int main()
{
   
    ll n, k;
    cin >> n >> k;

    string p;
    ll t = 0;
    while (n) {
        char a= n % k;
        a += '0';
        p = a + p;
        n /= k;
        t++;
    }
    cout << t << endl;

    return 0;

}

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

using namespace std;

int main(){
  int n;
 	cin >> n;
 	if (n%10  == 3){
 		cout << "bon" << endl;
 		}
 	else if(n%10 == 0|| n%10 == 1|| n%10==6 || n%10 == 8){
 		cout << "pon" << endl;
 		}
 	else{
 	cout << "hon" << endl;
 	}
  
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
#define PI 3.14159265358979
#define eps 1e-9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

ll mod = 1000000007;
ll dp[2001][2001];// dp[length][sum]

int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		ll n;
		cin>>n;
		vpll points(n),points1(n);
		rep(i,n){
			cin>>points[i].f>>points[i].s;
			points1[i].f = points[i].s;
			points1[i].s = points[i].f;
		}
		sort(all(points));
		sort(all(points1));
		ll ans = 0;
		repA(i,1,n-1){
			ans = max(ans,abs(points[i].f-points[0].f)+abs(points[i].s-points[0].s));
			ans = max(ans,abs(points1[i].f-points1[0].f)+abs(points1[i].s-points1[0].s));
		}
		repD(i,n-2,0){
			ans = max(ans,abs(points[i].f-points[n-1].f)+abs(points[i].s-points[n-1].s));
			ans = max(ans,abs(points1[i].f-points1[n-1].f)+abs(points1[i].s-points1[n-1].s));
		}
		ll sum[n],diff[n];
		rep(i,n){
			sum[i] = points[i].f+points[i].s;
			diff[i] = points[i].f-points[i].s;
		}
		sort(diff,diff+n);
		sort(sum,sum+n);
		ans = max3(ans,diff[n-1]-diff[0],sum[n-1]-sum[0]);
		rep(i,n){
			sum[i] = points1[i].f+points1[i].s;
			diff[i] = points1[i].f-points1[i].s;
		}
		sort(diff,diff+n);
		sort(sum,sum+n);
		ans = max3(ans,diff[n-1]-diff[0],sum[n-1]-sum[0]);
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 12704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, long long M){
    ll m = M / N;

    for (int i = m; i >= 1; i--)
    {
        if(M % i == 0){
            cout << i << endl;
            return;
        }
    }
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	for i := 0; i < n; i++ {
		a := eGetInt(scanner)
		if a%2 == 0 {
			if a%3 != 0 && a%5 != 0 {
				fmt.Println("DENIED")
				return
			}
		}
	}
	fmt.Println("APPROVED")
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
int m;
vector<int> a, bc, abc;
bool connected(int i) {
  if (abc[i] + 2 * bc[i] + 3 == abc[i + 1] - a[i + 1])
    return true;
  else
    return false;
}

signed main() {
  string s;
  cin >> s;
  int n = s.size();

  rep(i, n - 2) if (s.substr(i, 3) == "ABC") abc.push_back(i);
  for (auto&& u : abc) {
    int i = u - 1, cnt = 0;
    while (i >= 0 && s[i] == 'A') {
      i--;
      cnt++;
    }
    a.push_back(cnt);
  }
  for (auto&& u : abc) {
    int i = u + 3, cnt = 0;
    while (i < n - 1 && s.substr(i, 2) == "BC") {
      i += 2;
      cnt++;
    }
    bc.push_back(cnt);
  }
  //   for (auto&& u : abc) cout << u << ((&u < &abc.back()) ? " " : "\n");
  //   for (auto&& u : a) cout << u << ((&u < &a.back()) ? " " : "\n");
  //   for (auto&& u : bc) cout << u << ((&u < &bc.back()) ? " " : "\n");
  m = abc.size();
  int ans = 0;
  int M = 0;
  for (int i = 0; i < m; i++) {
    M += a[i] + 1;
    ans += M * (bc[i] + 1);
    if (i < m - 1) {
      if (!connected(i)) M = 0;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1788
#include <iostream>
#define mod 1000000007
using namespace std;
int n,a[105],dp[100005],qzh[100005],k;
int main(int argc, char** argv) {
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	qzh[k]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			dp[j]=qzh[min(k,j+a[i])];
			if(j>0) dp[j]-=qzh[j-1];
			dp[j]%=mod,dp[j]+=mod,dp[j]%=mod;
		}
		qzh[0]=dp[0];
		for(int j=1;j<=k;j++) qzh[j]=(dp[j]+qzh[j-1])%mod;
	}
	cout << dp[0];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
   int H,W;
   for(;;){
     cin >> H >> W;
   if(H!=0||W!=0){
        for(int i=0;i<H;i++){
            if(i%2==0){
                int j;
                for(j=0;j<W-1;j++){
                    if(j%2==0)
                        cout << "#" ;
                    else cout << "." ;
                }
                if(j%2==0)
                        cout << "#" << endl;
                    else cout << "." << endl;
            }
            else{
                int j;
                for(j=0;j<W-1;j++){
                    if(j%2==1)
                        cout << "#" ;
                    else cout << "." ;
                }
                if(j%2==1)
                        cout << "#" << endl;
                    else cout << "." << endl;
            }
        }
   }
   else break;
   cout << endl;
   }

   return 0;
}



Measured memory_bytes: 3084
N = gets.to_i
x = gets.split.map(&:to_i).sort
min = x[0]
max = x[N-1]

minimum = x.map{ |i| i**2 }.inject(0){ |r, i| r + i }
(min..max).each do |i|
  sum = 0
  x.each{ |e| sum += (e - i)**2 }
  minimum = sum if sum < minimum
end

puts minimum


Measured memory_bytes: 14284
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long r = 0, g = 0, b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            r ++;
        }else if(s[i] == 'G'){
            g ++;
        }else{
            b++;
        }
    }
    long long ans = r * g * b;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if((j-i)%2 == 0){
                int ave = (i+j)/2;
                if((s[i] != s[j] && s[i] != s[ave]) && s[j] != s[ave]){
                    ans --;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}





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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<vector<int>> xy(n, vector<int>(2));
  vector<int> a(n);
  vector<vector<int>> field(h, vector<int>(w));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> xy.at(i).at(j);
    }
    cin >> a.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    if (a.at(i) == 1) {
      for (int j = 0; j < h; j++) {
        for (int k = 0; k < xy.at(i).at(0); k++) {
          field.at(j).at(k) = 1;
        }
      }
    }
    if (a.at(i) == 2) {
      for (int j = 0; j < h; j++) {
        for (int k = xy.at(i).at(0); k < w; k++) {
          field.at(j).at(k) = 1;
        }
      }
    }
    if (a.at(i) == 3) {
      for (int j = 0; j < xy.at(i).at(1); j++) {
        for (int k = 0; k < w; k++) {
          field.at(j).at(k) = 1;
        }
      }
    }
    if (a.at(i) == 4) {
      for (int j = xy.at(i).at(1); j < h; j++) {
        for (int k = 0; k < w; k++) {
          field.at(j).at(k) = 1;
        }
      }
    }
  }
  
  int count = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (field.at(i).at(j) == 0) {
        count++;
      }
    }
  }
  
  cout << count << endl;    
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input();

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        cout << input() + input() << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
   int i,a,b,c;
   for(i=1;i<=3000;i++)
   {
   cin >> a >> b;
   if(a==0 && b==0)
   break;
   if(a > b)
   {
   c=a;
   a=b;
   b=c;
   }
   cout << a << " " << b << endl;
   }
}



Measured memory_bytes: 3072
function Main(input) {
  input = input.trim()
  input = input.split(" ");
if(input[0]==1){
input[0]=14;
}
if(input[1]==1){
input[1]=14;
}
input[0]-=0
input[1]-=0
if(input[0]>input[1]){
console.log("Alice");
}else if(input[0]<input[1]){
console.log("Bob");
}else{
console.log("Draw");
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int main() {
	int i, N, K, Q, a;
	cin >> N >> K >> Q;
	vector<int>A(N);

	/*for (i = 0; i < N; i++) {
		A[i] = K;
	}*/
	for (i = 0; i < Q; i++) {
		cin >> a;
		A[a - 1]++;
	}
	for (i = 0; i < N; i++) {
		if (K+A[i]-Q <=0)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 1024
import math

a, b, angle = map(int, input().split())
angle = math.radians(angle)

S = (a * b * math.sin(angle)) / 2
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(angle))
h = b * math.sin(angle)

print("%f %f %f" % (S, L, h))



Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, M, p[100100];
vector<int> v[100100];

int g (int i) { return p[i] == i ? i : p[i] = g(p[i]); }

int main () {
        scanf("%d %d", &N, &M);
        fo(i, 0, N) p[i] = i;
        fo(i, 0, N) {
                int sz; scanf("%d", &sz);
                fo(j, 0, sz) {
                        int a; scanf("%d", &a), a--;
                        v[a].PB(i);
                }
        }
        fo(i, 0, M) fo(j, 1, (int) v[i].size()) {
                p[g(v[i][j])] = g(v[i][j-1]);
        }
        fo(i, 1, N) if (g(i-1) != g(i)) return puts("NO"), 0;
        puts("YES");
        return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	Int a, b, x; cin >> a >> b >> x;
	Int out = b / x + 1;
	if (a > 0) {
		out -= (a-1) / x + 1;
	}
	print(out);








	return 0;
}

Measured memory_bytes: 256
a=gets.to_i
b=gets.to_i
c=gets.to_i
x=gets.to_i
cnt=0;
for i in 0..a do
  for j in 0..b do
    m=(x-500*i-100*j)
    if m >=0 && m%50==0 && m/50<=c
      cnt+=1;
  # printf("%d %d %d\n",i,j,m/50)
    end
  end
end

p cnt


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
int read()
{
  char c=0;
  int sum=0;
  while (c<'0'||c>'9')
    c=getchar();
  while ('0'<=c&&c<='9')
    sum=sum*10+c-'0',c=getchar();
  return sum;
}
int n,m,k;
long long fac[1000001],invfac[1000001],L[1000001],U[1000001];
long long fast_pow(long long a,int b)
{
  if (b==0) return 1;
  if (b&1) return fast_pow(a*a%mod,b/2)*a%mod;
  else return fast_pow(a*a%mod,b/2);
}
long long C(int x,int y)
{
  if (x<y) return 0;
  return fac[x]*invfac[y]%mod*invfac[x-y]%mod;
}
long long cnt,ans;
int main()
{
  n=read(),m=read(),k=read();
  fac[0]=1;
  for (int i=1;i<=n+m+k;++i) fac[i]=fac[i-1]*i%mod;
  invfac[n+m+k]=fast_pow(fac[n+m+k],mod-2);
  for (int i=n+m+k-1;i>=0;--i) invfac[i]=invfac[i+1]*(i+1)%mod;
  cnt=fast_pow(3,m+k)*invfac[n-1]%mod;
  for (int d=0;d<=m+k;++d)
    {
      L[d]=max(d-k,0);
      if (d==0) U[0]=(L[d]==0);
      else
	{
	  if (L[d]==L[d-1])
	    U[d]=(U[d-1]*2%mod+C(d-1,L[d]-1)%mod-C(d-1,m)%mod)%mod;
	  else
	    U[d]=(U[d-1]*2%mod-C(d-1,L[d]-1)%mod-C(d-1,m)%mod)%mod;
	}
      ans=(ans+fast_pow(3,mod-1-d)*fac[n-1+d]%mod*U[d]%mod*invfac[d]%mod)%mod;
    }
  printf("%lld\n",(ans*cnt%mod+mod)%mod);
  return 0;
}

Measured memory_bytes: 27208
n,m=map(int,input().split())
L=[]
for i in range(m):
    l=list(map(int,input().split()))
    s=0
    for j in range(l[0]):
        s+=2**(l[j+1]-1)
    L.append(s)
P=list(map(int,input().split()))
r=0
for i in range(1<<n):
	p=0
	for j in range(m):
		if bin(i&L[j]).count('1')%2==P[j]:
			p+=1
	if p==m:
		r+=1
print(r)

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

int main(){
  int N; cin >> N;
  int A[110];
  for(int i = 0; i < N; i++) cin >> A[i];
  
  int sum_a = 0;
  int sum_b = 0;
  
  //Aを降順でソートする
  sort(A, A + N, greater<int>());
  
  /*Aの奇数番目のみの和を求める。
  それはアリスのカードの和になる*/
  for(int i = 0; i < N; i += 2){
    sum_a += A[i];
  }
  /*偶数番目のみ*/
  for(int i = 1; i < N; i += 2){
    sum_b += A[i];
  }
  cout << sum_a - sum_b << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = m//n
ans = 0
for i in range(1, int(m**0.5)+1):
  if m%i == 0:
    if i <= k:
      ans = max(ans, i)
    if m//i <= k:
      ans = max(ans, m//i)
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Collections;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
    	Set<String> set = new HashSet<>();

    	for (int s = 1; s <= 13; s++) {
    		set.add("S " + s);
    	}

    	for (int h = 1; h <= 13; h++) {
    		set.add("H " + h);
    	}

    	for (int c = 1; c <= 13; c++) {
    		set.add("C " + c);
    	}

    	for (int d = 1; d <= 13; d++) {
    		set.add("D " + d);
    	}
		
      	int x = Integer.parseInt(br.readLine());
      	for(int i = 0; i < x; i++) {
          	String y = br.readLine();
          	set.remove(y);
        }
      
      	int size = set.size();
      	// S H C DのListを作る
      	List<Integer> S = new ArrayList<>();
      	List<Integer> H = new ArrayList<>();
        List<Integer> C = new ArrayList<>();
        List<Integer> D = new ArrayList<>();
      
      	for (int i = 0; i < size; i++) {
          	String z = String.valueOf(set.toArray()[i]);
        	if (z.contains("S")) {
              	int sn = Integer.parseInt(z.split(" ")[1]);
            	S.add(sn);
            } 
            if (z.contains("H")) {
              	int hn = Integer.parseInt(z.split(" ")[1]);
            	H.add(hn);
            }
          	if (z.contains("C")) {
                int cn = Integer.parseInt(z.split(" ")[1]);
            	C.add(cn);
            }
          	if (z.contains("D")) {
                int dn = Integer.parseInt(z.split(" ")[1]);
            	D.add(dn);
            }
          
        }
      
      	Collections.sort(S);
      	Collections.sort(H);
      	Collections.sort(C);
      	Collections.sort(D);

      	for(int s: S) {
        	System.out.println("S " + s);
        }
      	for(int h: H) {
        	System.out.println("H " + h);
        }
      	for(int c: C) {
        	System.out.println("C " + c);
        }
      	for(int d: D) {
        	System.out.println("D " + d);
        }
        
      	

    }
}


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

int main(){
  int N;
  cin >> N;
  int button[100010], now;
  for(int i=1; i<=N; ++i){
    cin >> button[i];
  }
  bool flag = false;
  int pre, next;
  int i = 1;
  int i_ = 1;
  int count = 0;
  pre = 0;
  next = 1;
  now = 1;
  for(int j=1;j<=N;++j){
    pre = i_; //1 1 3
    now = i; //1 3 4
    i_ = now;
    next = button[now];//3 4 2
    if(next == 2){
      flag = true;
      count++;
      break;
    }
    count++;
    i = next;
  }
  
  if(flag) cout << count << endl;
  else cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;

long long gcd(long long a,long long b)
{
	int l=0,s=0,r=0;
	if (a>b){
		l=a;s=b;
	} else {
		l=b;s=a;
	}
	while(l%s != 0){
		r=l%s;
		l=s;
		s=r;
	}
	return s;
}

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

int main(void) {
	vector<long long> r;
	while (true)
	{
		long long a[3]={0},m[3]={0},p[3]={1,1,1},re[3]={0};
		scanf("%ld %ld %ld %ld %ld %ld",&a[0],&m[0],&a[1],&m[1],&a[2],&m[2]);
		if (a[0]==0 && m[0]==0){
			break;
		}
		for (int i=0; i<3; i++)
		{
			int cnt=0;
			while (true)
			{
				p[i] = (p[i]*a[i])%m[i];
				cnt++;
				if (p[i]==1){break;}
			}
			re[i]=cnt;
		}
		long long result=0;
		result = lcm(lcm(re[0],re[1]),re[2]);
		r.push_back(result);
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;


int main(){
	int n,m;
	cin>>n>>m;
	long long x[100000];
	vector<long> d(m-1);
	for (int i = 0; i < m; ++i){
		cin>>x[i];
	}

	if(n>=m){
		cout<<0<<endl;
		return 0;
	}
	sort(x,x+m);

	int total=0;
	for (int i = 1; i < m; ++i){
		total+=abs(x[i]-x[i-1]);
		d.push_back(abs(x[i]-x[i-1]));
	}

	sort(all(d),greater<int>());
	for (int i = 0; i < n-1; ++i){
		total-=d[i];
	}

	cout<<total<<endl;

}

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


int main() {

long X,Y;
cin>>X>>Y;

bool flg=false;

for(int i=0;i<=X;i++){
  int leg=i*2+(X-i)*4;
  if(leg==Y) flg=true;
}

if(flg) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


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

#define int long long

const int MAX_N = 2000, MAX_M = 2000;
const int O = 1, INF = 100000;

string S, T;
int N, M;
int dp[MAX_N + 1][MAX_M + 1][2];

signed main()
{
    cin >> N >> M;
    cin >> S >> T;
    int ans = 0;
    for (int i = -1; i < N; i++)
    {
        for (int j = -1; j < M; j++)
        {
            for (int k = 0; k < 2; k++)
            {
                if (k == 0) dp[i + O][j + O][k] = -INF;
                if (i >= 0 && S[i] == "IO"[k])
                    dp[i + O][j + O][k] = max(dp[i + O][j + O][k], dp[i - 1 + O][j + O][1 - k] + 1);
                if (j >= 0 && T[j] == "IO"[k])
                    dp[i + O][j + O][k] = max(dp[i + O][j + O][k], dp[i + O][j - 1 + O][1 - k] + 1);
            }
            ans = max(ans, dp[i + O][j + O][0]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a<= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500 * a + 100 * b + 50 * c;
        if (total == X) ++res;
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll a, b; int k;
    cin >> a >> b >> k;

    int c = 0;
    while (c < k) {
        if (c % 2 == 0) {
            if (a % 2 == 1) a--;
            b += a / 2;
            a /= 2;
        } else {
            if (b % 2 == 1) b--;
            a += b / 2;
            b /= 2;
        }
        c++;
    }
    cout << a << " " << b << endl;
}


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

#define NUM 1000000000

int main(void){
	int a,b,flag=0;
	scanf("%d %d",&a,&b);
	
	for (int k = 1; k <= NUM; ++k){
		if(abs(a-k) == abs(b-k)){
			printf("%d\n",k);
			flag=1;
			break;
		}else{
			flag=0;
		}
	}
	if (flag == 0){
		printf("IMPOSSIBLE\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

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

int main(){

  ll a,b;
  cin >> a  >> b;
  cout << a/gcd(a,b)*b << endl;

}

Measured memory_bytes: 3620
n,k = map(int, input().split())
p = list(map(lambda z:int(z)-1, input().split()))
c = list(map(int, input().split()))

data = [[0 for i in range(n+1)] for j in range(n)]
loop = [10**10 for i in range(n)]
for i in range(n):
    j = i
    for t in range(1,n+1):
        j = p[j]
        data[i][t] += data[i][t-1] + c[j]
        if j == i:
            loop[i] = min(loop[i],t)

ans = -10**10
#print(data)
#print([data[i][loop[i]] for i in range(n)])

for i in range(n):
    for j in range(1,min(n,k)+1):
        if j > loop[i]:break
        if data[i][loop[i]] <= 0:
            ans = max(ans,data[i][j])
        else:
            ans = max(ans,data[i][loop[i]]*((k-j)//loop[i])+data[i][j])

print(ans)

Measured memory_bytes: 280488
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll manhattan(ll a, ll b, ll c, ll d) {
        return abs(a - c) + abs(b - d);
}

int main()
{
        ll N, M;
        cin >> N >> M;
        vll a(N), b(N);
        vll c(M), d(M);
        rep(i, 0, N) cin >> a[i] >> b[i];
        rep(i, 0, M) cin >> c[i] >> d[i];

        rep(i, 0, N) {
                ll mn = inf;
                ll mnpos = -inf;
                rep(j, 0, M) {
                        if (manhattan(a[i], b[i], c[j], d[j]) < mn) {
                                mn = manhattan(a[i], b[i], c[j], d[j]);
                                mnpos = j;
                        }
                }
                cout << mnpos+1 << endl;
        }
}

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

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll ans = n * (n + 1) / 2;
  itr(x, lcp_array(s, suffix_array(s))) ans -= x;
  cout << ans << endl;
}


Measured memory_bytes: 15636
# https://atcoder.jp/contests/abc131/tasks/abc131_c

def gcd(a, b)
  return a if b.zero?
  gcd(b, a % b)
end

def lcm(a, b)
  a * b / gcd(a, b)
end

A, B, C, D = gets.split.map(&:to_i)

f = ->(n) { n - n / C - n / D  + n / lcm(C, D) }
ans = f[B] - f[A - 1]

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define INF 1e9

using vi=vector<int>;
using vvi=vector<vi>;

vvi matmul(vvi a, vvi b){
	int n=a.size();
	auto d=vvi(n,vi(n,0));
	rep(i,n)rep(j,n)rep(k,n){
		d[i][j]|=a[i][k]*b[k][j];
	}
	return d;
}

vvi matpow(vvi a,int p){
	static map<int,vvi> memo;
	memo[1]=a;
	if(memo.find(p)==memo.end()){
		if(p%2){
			memo[p]=matmul(matpow(a,p-1),a);
		}else{
			auto r=matpow(a,p/2);
			memo[p]=matmul(r,r);		
		}
	}
	return memo[p];
}

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvi z(n,vi(n,0));
		auto e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=1;
		}

		vector<vvi> d(3);
		auto f=e;
		rep(p,3){
			d[p]=matpow(e,a[p]);
		}
		
		vi g(n,0);
		g[n-1]=1;
		rep(t,1000){
			bool next=0;
			vi ng(n,0);
			rep(i,n) if(!g[i]){
				bool ok=1,r;
				rep(p,3) [&]{r=0; rep(j,n) r|=(g[j] and d[p][i][j]); ok&=r;}();
				if(ok) ng[i]=next=1;
			}
			if(!next){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng[0]){
				cout<<t+1<<endl;
				break;
			}
			rep(i,n)g[i]|=ng[i];
		}
	}
	return 0;
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
// const int INF = 1e18+10;

/*----------------------------------------------*/


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

  vi a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));


  vi ch;
  vi cnt(1000001,0);
  vi t(1000001,1);//1なら使ってok

  rep(i,n){
    int k=a[i];
    cnt[k]++;
    if(cnt[k]==1){ //ひとつめ     
      if(t[k]==1){ //つかってok
        for(int j=2;j*k<=1000000;j++){
          t[j*k]=0;
        }      
      }

    }
    if(cnt[k]==2){
      t[k]=0;
    } 

  }
  // rep(i,ch.size()) cout<<ch[i]<<endl;
  int ans=0;
  rep(i,n){
    ans+=t[a[i]];
  }
  cout<<ans<<endl;
  

  return 0;
}


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

using namespace std;
using ll = long long;

int n, m;

ll adj[40];
int c[40];

void outbin(ll b) {
    for (int i = n - 1; i >= 0; --i) {
        cout << ((b >> i) & 1LL ? 1 : 0);
    }
    cout << endl;
}

int dfs(int k, ll f) {
    if (k == n - 1) {
        f = ~adj[k] & f;
        int cost = 0;
        for (int i = 0; i < n; ++i)
            if (~f >> i & 1LL) cost += c[i];
        return cost;
    }

    int mincost = 1000000;
    for (int i = 0; i < n; ++i) {
        if ((adj[k] >> i & 1LL) & (f >> i & 1LL)) {
            int res = dfs(i, ~adj[k] & f);
            if (res < mincost) mincost = res;
        }
    }

    return mincost;
}

int main() {

    cin >> n >> m;

    for (int i = 0; i < n; ++i) cin >> c[i];
    for (int i = 0; i < n; ++i) adj[i] = 0;

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        //cout << u << ", " << v << endl;
        adj[u] |= 1LL << v;
        adj[v] |= 1LL << u;
    }

    cout << dfs(0, ~1LL) << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
int n, x, y, u, ans = 1e9, pa[][2] = {{0,2},{4,7},{8,9},{6,5},{10,11},{3,1}};
char us[] = "RLUD", uc;
set<P> st[12];
void chmin(int &a, int b){if(a>b)a=b;}
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("\n%d %d %c", &x, &y, &uc);
		rep(i,4) if(us[i] == uc) u = i;
		st[u].emplace(x+y,x*2);
		st[u+4].emplace(x-y,x*2);
		st[u+8].emplace(u<2?y:x,u<2?x:y);
	}
	for(auto [l, r]: pa) for(auto li: st[l]){
		auto it = st[r].lower_bound(li);
		if(it != st[r].end() && it->first == li.first) chmin(ans,it->second-li.second);
	}
	if(ans != 1e9) printf("%d\n", ans*5);
	else puts("SAFE");
}

Measured memory_bytes: 31808
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	if(a+b <= 2*c) cout << a*x + b*y << endl;
	else{
		int ans = a*x + b*y;
		for(int i=1; i<=max(x,y)*2;i++){
			int now = i*c;
			if(i%2!=0) continue;
			int xx = x - i/2, yy = y - i/2;
			if(xx > 0 ) now += xx*a;
			if(yy > 0 ) now += yy*b;
			ans = min(now,ans);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        n: usize,
        p: [f64; n]
    }

    let mut dp = vec_md![0f64;n+1;n+1];
    dp[0][0] = 1f64;
    for i in 0..dp.len() {
        for j in 0..dp[0].len() {
            if i+1<dp.len() && j+1<dp[0].len() {
                dp[i+1][j+1] += dp[i][j] * p[i];
            }
            if i+1<dp.len() {
                dp[i+1][j] += dp[i][j] * (1f64 - p[i]);
            }
        }
    }
    let mut ret = 0f64;
    for i in (n+1)/2..n+1 {
        ret += dp[n][i];
    }
    println!("{}", ret);
}

Measured memory_bytes: 90364
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a.push_back(2000000000);
    sort(a.begin(),a.end());
    int count = 1;
    vector<long long > b;
    /*for(int i=0;i<n+1;i++){
        cout << a[i] << " ";
    }
    cout << endl;*/
    for(int i=0;i<n;i++){

                //cout << "count=" <<count << endl;
        if(a[i] == a[i+1]){
            count ++;
        }
        else{
            if(count >= 2 && count < 4){
                b.push_back(a[i]);
                count=1;
            }
            else if(count >= 4){
                b.push_back(a[i]);
                b.push_back(a[i]);
                count =1;
            }
            else{
                count=1;
            }
        }
    }


    if(b.size()>=2){
        sort(b.begin(),b.end());
        reverse(b.begin(),b.end());

    /*for(int i=0;i<b.size();i++){
        cout << b[i] << " ";
    }
    cout << endl;*/
        cout << b[0]*b[1]<<endl;
    }
    else{
        cout << "0"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

const int mod=1000000007;

int mpow(int a,int b)
{
	if(b==0)
		return 1;
	if(b%2)
		return 1LL*a*mpow(a,b-1)%mod;
	else
	{
		int d=mpow(a,b/2);
		return 1LL*d*d%mod; 
	}
}

int main()
{
	ios::sync_with_stdio(false);
	
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	
	int fact[200010]={1,1};
	
	for(int i=1;i<200010;i++)
		fact[i]=1LL*fact[i-1]*i%mod;
	
	int ans=0;
	
	for(int i=1;i<=h-a;i++)
	{
		int t=1;
		t=1LL*t*fact[b+i-2]%mod*mpow(1LL*fact[b-1]*fact[i-1]%mod,mod-2)%mod;
		t=1LL*t*fact[h-i+w-b-1]%mod*mpow(1LL*fact[h-i]*fact[w-b-1]%mod,mod-2)%mod;
		ans=(ans+t)%mod;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int r[4];
int s[2];
int maxc,m;
int main(){
	cin >>r[0];
	cin >>r[1];
	cin >>r[2];
	cin >>r[3];
	cin >>s[0];
	cin >>s[1];
	maxc=r[0]+r[1]+r[2]+r[3]+s[0]+s[1];
	m=101;
	for(int i=0;i<4;i++){
		if(r[i]<m)m=r[i];
	}
	maxc-=m;
	m=101;
	for(int i=0;i<2;i++){
		if(s[i]<m)m=s[i];
	}
	maxc-=m;
	cout << maxc<<endl;
	return 0;
}

Measured memory_bytes: 3048