akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define inf 1000000
#define NIL -1

void f(void);
int n,M[100][100];

int main()
{
  int k,u,c,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = inf;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  f();

  return 0;
}

void f()
{
  int d[100],color[100],min,u,i,v,g;

  for(i=0;i<n;i++){
    d[i] = inf;
    color[i] = 0;
  }

  d[0] = 0;
  color[0] = 1;

  while(1){
    min = inf;
    u = NIL;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<min){
        min = d[i];
        u = i;
      }
    }

    if(u == NIL) break;
    color[u] = 2;

    for(v=0;v<n;v++){
      if(color[v]!=2 && M[u][v]!=inf){
        if(d[u] + M[u][v] < d[v]){
          d[v] = d[u] + M[u][v];
          color[v] = 1;
        }
      }
    }
  }

  for(i=0;i<n;i++){
    if(d[i] == inf) g = -1;
    else g = d[i];
    printf("%d %d\n",i,g);
  }
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    sort ALL(A);A.pb(INF);
    ll ans = 0;
    REP(i,N){
        repp(j,i,0){
            auto Iter = upper_bound(A.begin(),A.end()-(N-j+1),A[i]-A[j]);
            auto cnt = A.end()-(N-j+1) - Iter;
            ans += cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,q;
	cin>>n>>q;
	char ar[n+1];
	cin>>ar;
	ll sm[n+1]={0};
	sm[0]=0;

	for(i=1;i<n;i++){
		if(ar[i]=='C'&&ar[i-1]=='A'){
			sm[i+1]=1;
		}
	}

	//cout<<sm[0]<<" ";
	for(i=1;i<=n;i++){
		sm[i]+=sm[i-1];
		//cout<<sm[i]<<" ";
	}
	//cout<<endl;

	ll a,b;
	while(q--){
		cin>>a>>b;
		l=sm[b]-sm[a];
		//if(ar[a-1]=='C') l--;
		//l=max((ll)0,l);
		cout<<l<<endl;
	}
	return 0;
}


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

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

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

#define iter(i, n) for (int i = 1; i <= n; ++i)

const int NR = 2010;
const int QR = 2e5 + 100;

struct Po { int x, y, id; } p[NR * NR * 3];
int t[NR], x, n, m, q, len, ans[QR], xl[QR], xr[QR], yl[QR], yr[QR];
char s[NR][NR];


bool cmp(Po a, Po b) {
	if (a.x != b.x) return a.x < b.x;
	if (a.y != b.y) return a.y < b.y;
	return (a.id != 0) < (b.id != 0);
}

void inc(int x) { for (; x <= m; x += x & -x) ++t[x]; }
int sum(int x) { int s = 0; for (; x; x -= x & -x) s += t[x]; return s; }

int abs(int x) { return x > 0 ? x : -x; }
int sgn(int x) { return x > 0 ? +1 : x < 0 ? -1 : 0; }

void solve() {
	sort(p + 1, p + len + 1, cmp);
	iter(i, m) t[i] = 0;
	iter(i, len) {
		if (p[i].id == 0) inc(p[i].y);
		else ans[abs(p[i].id)] += sgn(p[i].id) * sum(p[i].y);
	}
}

void addq(int xl, int xr, int yl, int yr, int d, int i) {
	--xl; --yl;
	p[++len] = (Po) { xr, yr, +d * i };
	if (xl) p[++len] = (Po) { xl, yr, -d * i };
	if (yl) p[++len] = (Po) { xr, yl, -d * i };
	if (xl && yl) p[++len] = (Po) { xl, yl, +d * i };
}

void addm(int x, int y) { p[++len] = (Po) { x, y, 0 }; }


int main() {
	scanf("%d%d%d", &n, &m, &q);
	iter(i, n) scanf("%s", s[i] + 1);
	iter(i, q) scanf("%d%d%d%d", &xl[i], &yl[i], &xr[i], &yr[i]);

	iter(i, n) iter(j, m) if (s[i][j] == '1') addm(i, j);
	iter(i, q) addq(xl[i], xr[i], yl[i], yr[i], +1, i);
	solve();
	
	len = 0;

	iter(i, n) iter(j, m - 1) if (s[i][j] == '1' && s[i][j + 1] == '1') addm(i, j);
	iter(i, q) if (yl[i] < yr[i]) addq(xl[i], xr[i], yl[i], yr[i] - 1, -1, i);
	solve();

	len = 0;

	iter(i, n - 1) iter(j, m) if (s[i][j] == '1' && s[i + 1][j] == '1') addm(i, j);
	iter(i, q) if (xl[i] < xr[i]) addq(xl[i], xr[i] - 1, yl[i], yr[i], -1, i);
	solve();

	iter(i, q) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 50304
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var num = parseInt(line[0]);
    var data = input[1].split(" ");
 
    var flag = new Array(9).fill(0);
 
    var color8 = 0;
 
    for(var i = 0;i<num;i++){
        data[i] = Math.floor(parseInt(data[i])/400);
        if(data[i]>8){
            data[i] = 8;
        }
//        console.log(data[i]);
        flag[data[i]]++;
    }
    
    for(var i = 0;i<8;i++){
        if(flag[i]>0){
            color8++;
        }
    }
    
//    console.log(flag);
    var max = color8+flag[8];
//    if(max>=8){
//        max = 8;
//    }
    if(color8===0){
        color8 = 1;
    }
    console.log(color8+" "+max);
 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <cstdio>
#define il inline
#define ri register
#define Size 5500
#define intmax 0x7fffffff
using namespace std;
bool a[Size],b[Size];
int A[Size],B[Size],at,bt;
il void get(char&);
int main(){
	int n;char c;scanf("%d",&n);
	for(int i(1);i<=n;++i)get(c),a[i]=c^48;
	for(int i(1);i<=n;++i)get(c),b[i]=c^48;
	for(int i(2);i<=n;++i){
		if(a[i]!=a[i-1])A[++at]=i-1;
		if(b[i]!=b[i-1])B[++bt]=i-1;
	}A[at+1]=B[bt+1]=n;
	int ans(intmax),beg(a[A[1]]==b[B[1]]?1:0);
	for(int i(beg-n-(n&1)),j,k,sum;i<=(beg+n+(n&1));i+=2){sum=0;
		for(j=(i<=0?1:2-i),k=(i<=0?i:1);j<=at||k<=bt;++j,++k){
			int u(j),v(k);
			if(u<0)u=0;if(u>at)u=at+1;
			if(v<0)v=0;if(v>bt)v=bt+1;
			sum+=abs(A[u]-B[v]);
		}ans=min(ans,sum);
	}printf("%d",ans);
	return 0;
}
il void get(char &c){
	while(c=getchar(),c==' '||c=='\n'||c=='\r');
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	string S;

	cin >> S;
	
	string ret = "Good";
	char c_before = ' ';

	for (auto c : S) {
		if (c == c_before) {
			ret = "Bad";
		}
		c_before = c;
	}

	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
		   tree_order_statistics_node_update> oset;
*/
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) { __print(x.first); cout << ','; __print(x.second); }
template<typename T>
void __print(const T &x) {int f = 0; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); }
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define d(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define d(x...)
#endif
 
#define IO            ios::sync_with_stdio(false);cin.tie(0);
//#define clock()       std::chrono::high_resolution_clock::now()
//#define duration(x,y) std::chrono::duration_cast<std::chrono::milliseconds>(y-x).count()
 
#define ll            long long
#define pi            pair<int,int>
#define pii           pair<pi,int>
#define pl            pair<ll,ll>
#define vi            vector<int>
#define vl            vector<ll>
#define vll           vector<vl>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define vpl           vector<pl>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,val,n)   for(int i=val;i<n;i++)
#define rfo(i,val,j)  for(int i=val;i>=j;i--)
#define all(x)        x.begin(),x.end()
#define inf           INT_MAX
#define endl          '\n'
	
const int N=2e5+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
 	
	IO

	cout<<fixed<<setprecision(12);
	long double n , ans=1;
	cin>>n;

	if((ll)n%3==0){
		cout<< (n/3) * (n/3) * (n/3);
		return 0;
	}
	ans *= n/3;
	//d(ans);
	n -= n/3;
	ans *= n/2;
	//d(ans);
	n -= n/2;
	ans *= n;

	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意


def choose(n,k):
    if 0 <= k <= n:
        res = 1
        for i in range(k):
            res *= n-i
            res //= (i+1)
        return res
    else:
        return 0

#n = int(input())
n,a,b = [int(i) for i in readline().split()]
v = [int(i) for i in readline().split()]

v.sort(reverse=True)
s = sum(v[:a])

print(s/a)
from bisect import *

c = v[a]
ans = 0
if v[a-1] != v[a]:
    ans = 1
else:    
    v.sort()
    l = bisect_left(v,c)
    r = bisect_right(v,c)
    if r != n:
        ans = choose(r-l,r+a-n)
    else:
        for i in range(r+a-n,r+b-n+1):
            ans += choose(r-l,i)

print(ans)
        
    







    
    
    
    
    

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
	int D, G, p[11], c[11];
	cin >> D >> G;
	for (int i = 0; i < D; ++i) {
		cin >> p[i] >> c[i];
	}

	int ans = 1e9;
	for (int mask = 0; mask < (1 << D); ++mask) {
		int s = 0, num = 0, rest_max = -1;
		for (int i = 0; i < D; ++i) {
			if (mask >> i & 1) {
				s += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else {
				rest_max = i;
			}
		}
		if (s < G) {
			int s1 = 100 * (rest_max + 1);
			int need = (G - s + s1 - 1) / s1;
			if (need >= p[rest_max]) {
				continue;
			}
			num += need;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define FOR(x) for(int x=0;x<=9;x++)
using namespace std;

int main(){
  int n;
  while(cin>>n){
    int count=0;
    FOR(a){
      FOR(b){
	FOR(c){
	  FOR(d){
	    if(a+b+c+d==n) count++;
	  }
	}
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
 
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a + b == c){
        	System.out.println("Yes");
        }else if(a + c == b){
        	System.out.println("Yes");
        }else if(c + b == a){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35796
object Main extends App {
  import scala.io.StdIn._



  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  var depth = 1
  var used = 1
  var rest = n - 1
  while ((used + k - 1) / k <= rest){
    val use = (used + k - 1) / k
    depth += 1
    used += use
    rest -= use
  }
  println(depth)
}


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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> p;
    rep(i,N){
        int a;
        cin>>a;
        p.push_back(a);
    }
    sort(p.begin(),p.end());
    int count=0;
    rep(i,K)count+=p.at(i);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3632
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,M = LI()
if N <= 1:
    n = 0
else:
    n = math.factorial(N)//((math.factorial(N-2))*(math.factorial(2)))
if M <= 1:
    m = 0
else:
    m = math.factorial(M)//((math.factorial(M-2))*(math.factorial(2)))
print(n+m)

Measured memory_bytes: 4268
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n < 3) {
			System.out.println(0);
			return;
		}
		int[] nums = new int[n];
		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		Arrays.sort(nums);
		int ans = 0;
		for (int i = 0; i < n - 2; i++) {
			for (int j = i + 1; j < n - 1; j++) {
				for (int k = j + 1; k < n; k++) {
					if (nums[i] != nums[j] && nums[j] != nums[k] && nums[i] != nums[k]) {
						if (nums[i] + nums[j] > nums[k]) {
							ans++;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}


























Measured memory_bytes: 36472
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <tuple>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

using ll=long long;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vll> vl2d;
typedef vector <vi> vi2d;
typedef vector <char> vc;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <char,int> mci;
typedef map <int,int> mii;
typedef map <long,long> ml;
typedef map <string,string> mss;
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define foreach(x,arr) for(auto& x:arr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define endl '\n' // Normal `cout << endl` flushes the output every time wich hit performance badly
#define INF 1000000000
#define MOD 1000000007
#define deb(x) cout<<#x<<": "<<x<<endl;
#define printArray(arr) for(auto x: arr) { cout<<x<<"\n"; }
#define printMatrix(mat) for(auto x: mat) { cout<<" "; printArray(x); cout<<endl; }
#define printMap(mmap) for(auto p: mmap) { cout<< p.first<<": "<<p.second<<endl; }
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define forch(ch,str) for(char& c : str)
#define FILL(a,b) memset(a,b,sizeof(a))
//Swift related stuff
#define append push_back
#define nil nullptr
#define guard(_condition) if (bool(_condition)){}
#define count size()
#define let auto
#define var auto
#define startsWith(str) rfind(str, 0)
#define prq priority_queue
#define tostr(argument) to_string(argument)
#define alphabet "abcdefghijklmnopqrstuvwxyz"

void join(const vector<string>& v, char c, string& s) {

   s.clear();

   for (vector<string>::const_iterator p = v.begin();
        p != v.end(); ++p) {
      s += *p;
      if (p != v.end() - 1)
        s += c;
   }
}

ll maxHapiness(int n, vl2d hap) {
    vector<vector<ll>> dp(n, vector<ll>(3, 0));
    dp[0][0] = hap[0][0];
    dp[0][1] = hap[0][1];
    dp[0][2] = hap[0][2];
    rep(i, 1, n) {
        dp[i][0] = hap[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = hap[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = hap[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    return max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); // Fast input
    
    int n;
    cin>>n;
    vl2d hap(n,vll(3,0));
    rep(i, 0, n) {
        ll o,t,th;
        cin>>o>>t>>th;
        hap[i][0] = o;
        hap[i][1] = t;
        hap[i][2] = th;
    }
    cout<<maxHapiness(n, hap)<<endl;
    return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int n,k;
    cin>>n>>k;

    vector<int> a(n);

    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
    }

    sort(a.begin(),a.end(),greater<int>());
    int sum = 0;
    for ( int i = k ; i < a.size() ; i++ )
    {
        sum += a[i];
    }

    cout<<sum<<endl;

    return 0;
}

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


int main(){
    int N, ac=0, wa=0, tle=0, re=0;
    cin >> N;
    rep(i,N){
        string x;
        cin >> x;
        if(x=="AC"){
            ac++;
        }
        else if(x=="WA"){
            wa++;
        }
        else if(x=="TLE"){
            tle++;
        }
        else if(x=="RE"){
            re++;
        }
    }

    cout << "AC" << " " << "x"<< " "<< ac << endl;
    cout << "WA" << " " << "x"<< " "<< wa << endl;
    cout << "TLE" << " " << "x"<< " "<< tle << endl;
    cout << "RE" << " " << "x"<< " "<< re << endl;

}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;


    int n;

    cin >> n;

    long double x , sum = 0;

    string st;



    for(int i=0; i<n; i++)
    {
        cin >> x >> st;

        if(st=="JPY")
        {
            sum += (x*1.00);
        }
        else{
            sum += (x*380000.00000000*1.0);
        }
    }

    cout << setprecision(10) << sum << endl;





    return 0;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  
  int S = A + B;
  int T = A - B;
  int U = A * B;
  
  if (S >= T && S >= U) {
    cout << S << endl;
  } else if (T >= S && T >= U) {
    cout << T << endl;
  } else {
    cout << U << endl;
  }
}

Measured memory_bytes: 256
D = int(input())

str_c = "Christmas"

if D==25:
    print(str_c)

elif D==24:
    str_d = str_c + " Eve"
    print(str_d)

elif D==23:
    str_d = str_c + " Eve Eve"
    print(str_d)

elif D==22:
    str_d = str_c + " Eve Eve Eve"
    print(str_d)
    

Measured memory_bytes: 9000
import java.io.*;

class Main {
    public static void main(String [] args){
        
        for(int i = 1; i <= 9; ++i){
            for(int j = 1; j <= 9; ++j){
                System.out.println(i + "x" + j + "=" + i * j);
            }
        }
    }
}

Measured memory_bytes: 24088
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

double dp[301][301][301];


double fun(int& n, int x, int y, int z)
{
    //Base case
    if(x==0 && y==0 && z==0)
    return 0;
    if(x<0 || y<0 || z<0)
    return 0;

    //Lookup
    if(dp[x][y][z] > -0.9)
    return dp[x][y][z];

    //Rec case
    double ans = n + (x*fun(n,x-1,y,z)) + (y*fun(n,x+1,y-1,z)) + (z*fun(n,x,y+1,z-1));
    return dp[x][y][z] = ans/(x+y+z);
}

int main()
{
    fast_io;
    
    memset(dp,-1,sizeof(dp));
    int n,j;
    cin>>n;

    int o=0,tw=0,th=0;

    for(int i=0;i<n;i++)
    {
        cin>>j;
        if(j == 1)
        o++;
        else if(j == 2)
        tw++;
        else
        th++;
    }
    cout<<sp(10)<<fun(n,o,tw,th)<<endl;

    return 0;
}

Measured memory_bytes: 213376
from collections import Counter


n, k = map(int, input().split())
lst_A = list(map(int, input().split()))


set_A = set(lst_A)
cnt_A = sorted(Counter(lst_A).items(), key=lambda x:x[1])
num_change = len(set_A) - k
ans = 0
if num_change > 0:
    for i in range(num_change):
        ans += cnt_A[i][1]


print(ans)


Measured memory_bytes: 50588
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n1,n2,m;cin>>n1>>n2>>m;
    vi a(n1);
    vi b(n2);

    int ma = INF;
    rep(i, n1){
        cin>>a[i];
        chmin(ma, a[i]);
    }

    int mb = INF;
    rep(i, n2){
        cin>>b[i];
        chmin(mb, b[i]);
    }

    vi x(m), y(m), c(m);
    int ans = ma+mb;
    rep(i, m){
        cin>>x[i]>>y[i]>>c[i];
        x[i]--;y[i]--;
        chmin(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>

#include<iostream>
using namespace std;

std::vector< std::vector<int> > graph;
std::vector<int> c;


void rr(int root, int count) {
	if (count == 0){
		return;
	}
	for(const auto &a : graph[root]) {
		c[a] += count;

		rr(a, count);
	}
}

void eee(int root, int count) {
	c[root] += count;
	for (const auto &a : graph[root]) {
		eee(a, c[root]);
	}
}

int main()
{

	std::string s, t;
	cin >> s;

	bool b = true;
	for (int i = 0; i < s.length(); ++i) {
		char a = s[i];

		if ((i % 2) == 1) {
			std::string aaa = "LUD";
			auto t = aaa.find(a);

			if (t == std::string::npos) {
				b = false;
				break;
			}
		}else{
			std::string aaa = "RUD";
			auto t = aaa.find(a);

			if (t == std::string::npos) {
				b = false;
				break;
			}
		}
	}

	if (b) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}


	return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

class cell{
public:
  int x;
  int y;
  cell(int x, int y);
};

cell::cell(int px, int py){
  x =px;
  y = py;
}

int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }
  queue<cell> wait;
  int dist[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      dist[i][j] = -1;
    }
  }
  dist[0][0] = 0;
  wait.push(cell(0,0));
  while(wait.size()>0){
    int x = wait.front().x;
    int y = wait.front().y;
    if(x+1<h){
      if(s[x+1][y]=='.'&&dist[x+1][y]==-1){
        dist[x+1][y]=dist[x][y]+1;
        wait.push(cell(x+1,y));
      }
    }
    if(y+1<w){
      if(s[x][y+1]=='.'&&dist[x][y+1]==-1){
        dist[x][y+1]=dist[x][y]+1;
        wait.push(cell(x,y+1));
      }
    }
    if(x-1>=0){
      if(s[x-1][y]=='.'&&dist[x-1][y]==-1){
        dist[x-1][y]=dist[x][y]+1;
        wait.push(cell(x-1,y));
      }
    }
    if(y-1>=0){
      if(s[x][y-1]=='.'&&dist[x][y-1]==-1){
        dist[x][y-1]=dist[x][y]+1;
        wait.push(cell(x,y-1));
      }
    }
    wait.pop();
  }
  if(dist[h-1][w-1]==-1){
    cout << -1 << endl;
  }else{
    int whitecnt = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(s[i][j]=='.') whitecnt++;
      }
    }
    cout << whitecnt - dist[h-1][w-1] - 1 << 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++)
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int c2 = 0, c4 = 0, c0 = 0;
    rep(i, n)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 4 == 0)
                c4++;
            else
                c2++;
        }
        else
        {
            c0++;
        }
    }
    if (c2 == 0)
    {
        if (c4 + 1 >= c0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
    {
        if (c4 >= c0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> a = new ArrayList<>();
        IntStream.range(0, 3 * n).forEach(i -> a.add(sc.nextLong()));

        Collections.sort(a);
        long sum = 0;
        for (int i = 0; i < 3 * n; i++) {
            if (i < n) {
                continue;
            }
            if ((i - n) % 2 == 1) {
                continue;
            }
            sum += a.get(i);
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 100072
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    map<string, int> m;
    int idx = 0;
    vector<int> cnt(N);
    REP(i, N) {
        auto itr = m.find(S[i]);
        if(itr == m.end()) {
            m[S[i]] = idx;
            idx++;
        }
        cnt[m[S[i]]]++;
    }
    int ans = 0;
    REP(i, N) {
        if(cnt[i] > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 25856
from collections import deque
N, M, Q = [int(a) for a in input().split()]
q = [None] * Q
for i in range(Q):
    q[i] = [int(x) for x in input().split()]

stk = deque([[i] for i in range(1, M + 1)])
ans = 0
while len(stk) > 0:
    A = stk.pop()
    if len(A) == N:
        temp = 0
        for i in range(Q):
            if A[q[i][1] - 1] - A[q[i][0] - 1] == q[i][2]:
                temp += q[i][3]
        ans = max(ans, temp)
        continue
    for i in range(A[-1], M + 1):
        stk.append(A + [i])

print(ans)

Measured memory_bytes: 9460
n,m,q=map(int,input().split())
mat=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    mat[l][r]+=1

for i in range(n+1):
    for j in range(n+1):
        mat[i][j]+=mat[i-1][j]
        mat[i][j]+=mat[i][j-1]
        mat[i][j]-=mat[i-1][j-1]

for i in range(q):
    l,r=map(int,input().split())
    ans=mat[r][r]+mat[l-1][l-1]-mat[l-1][r]-mat[r][l-1]
    print(ans)

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

int main(){
    int n,k;
    cin>>n;
    cin>>k;
    vector<long long> arr(n);
    for(int i=0; i<n; i++) cin>>arr[i];

    // for(int i=0; i<n; i++) cout<<arr[i]<<" ";
    // cout<<endl;

    vector<long long> dp(n, INT_MAX);
    dp[0]=0;
    for(int i=1; i<n; i++){
        for(int j=i-1; j>=max(0, i-k); j--){
            dp[i] = min(dp[i], abs(arr[j]-arr[i])+dp[j]);
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    map<int, int> stick;
    vector<int> len;
    rep(i, N) {
        int A;
        cin >> A;
        if (stick.count(A) == 0) {
            stick[A] = 1;
            len.push_back(A);
        }
        else {
            stick[A]++;
        }
    }

    sort(all(len));
    reverse(all(len));

    int cnt = 0;
    ll a1 = 0, a2 = 0;
    rep(i, len.size()) {
        //cout << len[i] << ":" << stick[len[i]] << endl;
        if (stick.count(len[i]) != 0 && stick[len[i]] >= 2) {
            if (stick[len[i]] >= 4) {
                if (a1 == 0) {
                    a1 = len[i];
                    cnt++;
                }
                if (a2 == 0) {
                    a2 = len[i];
                    cnt++;
                }
            }
            if (a1 == 0) {
                a1 = len[i];
                cnt++;
            }
            else if (a2 == 0) {
                a2 = len[i];
                cnt++;
            }
        }
        if (cnt == 2) break;
    }

    if (cnt == 2) {
        cout << 1LL * a1 * a2 << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}

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


const int MAX = 210000;
const ll MOD = 998244353;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long fac[MAX], finv[MAX], inv[MAX];

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

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


int main() {
    COMinit();

    ll N, M, K;
    cin >> N >> M >> K;

    ll ans = 0;
    rep(k, K+1) {
        ll ans_i;
        ans_i = COM(N-1, k) * M;
        ans_i %= MOD;
        ans_i *= modpow(M-1, N-1-k, MOD);
        ans_i %= MOD;
        ans += ans_i;

        // ans += COM(N-1, k) * M * modpow(M-1, N-1-k, MOD);
        ans %= MOD;
    }

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

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

long a[200010];

int main(){long N, K;
cin >> N >> K;
erep(i, N) cin >> a[i];
vector<long> num(200010);

rep(i, 200010) num.at(i) = 0;
erep(i, N) num.at(a[i])++;
sort(num.begin(), num.end());
long start;
rep(i, 200010){
    if(num.at(i) != 0){
        start = i;
        break;
    }
}
long ans = 0;
long t = 0;
for(long i = 200010 - start; i >= K + 1; i--){
    ans += num.at(start + t);
    t++;
}

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

Measured memory_bytes: 3328
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>vc;
int main()
{




    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        vc.push_back(make_pair(i+1,x));
    }


sort(vc.begin(),vc.end(),[](const pair<int,int> &left, const pair<int,int> &right) {
           return left.second < right.second;



});
    for(auto x: vc)cout<<x.first<<" ";






    return 0;
}

Measured memory_bytes: 1780
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if n==1 and m==1:
        ans=1
    # n,m=1,1を除外してるからどっちか１だったら他方の-2でok
    elif m==1 or n==1:
        ans=max(n,m)-2
    else:
        ans=(n-2)*(m-2)
    print(ans)
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    int sum = abs(a.at(0));
    for(i = 1;i < n;++i){
        sum += abs(a.at(i)-a.at(i-1));
    }
    sum += abs(a.at(n-1));
    int temp = sum-abs(a.at(0))-abs(a.at(1)-a.at(0))+abs(a.at(1));
    cout << temp << endl;
    for(i = 1;i < n-1;++i){
        int temp1 = sum-abs(a.at(i)-a.at(i-1))-abs(a.at(i+1)-a.at(i))+abs(a.at(i+1)-a.at(i-1));
        cout << temp1 << endl;
    }
    int temp2 = sum-abs(a.at(n-1)-a.at(n-2))-abs(a.at(n-1))+abs(a.at(n-2));
    cout << temp2 << endl;
    return 0;
}

Measured memory_bytes: 1664
k = int(input())
if k <= 12:
    print(k)
    exit()

cnt = []
cnt.append([[0]*10 for i in range(10)])
cnt.append([[1 if i == j else 0 for j in range(10)] for i in range(10)])
# cnt[1][0][0] = 0

total = 9

loop = True
x = 1
head = 1
while loop:
    x += 1
    cnt.append([[0] * 10 for _ in range(10)])
    for h in range(0, 10):
        head_total = 0
        head = h
        cnt[x][h][0] = cnt[x - 1][h][0] + cnt[x - 1][h][1]
        head_total += cnt[x][h][0]
        for i in range(1, 9):
            cnt[x][h][i] = cnt[x - 1][h][i - 1] + \
                cnt[x - 1][h][i] + cnt[x - 1][h][i + 1]
            head_total += cnt[x][h][i]

        cnt[x][h][9] = cnt[x - 1][h][8] + cnt[x - 1][h][9]
        head_total += cnt[x][h][9]
        if h == 0:
            continue

        if total + head_total >= k:
            loop = False
            break
        else:
            total += head_total


result = head

for i in range(x - 1, 0, -1):

    for h in [head - 1, head, head + 1]:
        if h < 0 or 9 < h:
            continue
        t = sum(cnt[i][h])
        if total+t < k:
            total += t
        else:
            result = result * 10 + h
            head = h
            break
print(result)


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

int main() {
    int N;
    cin >> N;
    int A[N];
    int max_a=0,min_a=0;
    int diff = 0;
    for (int i=1;i<=N;i++) {
        cin >> A[i];
        if (i==1) max_a=A[i],min_a=A[i];
        if (max_a<A[i]) max_a = A[i];
        if (A[i]<min_a) min_a = A[i];
    }
    cout << max_a - min_a << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){

  int N, Y;
  std::cin >> N >> Y;
  int res10000=-1, res5000=-1, res1000=-1;
  for (int i = 0; i <= N; ++i)
  {
    for (int j = 0; j <= N; ++j)
  {
      int k = N-i-j;
      int total = 10000*i + 5000*j + 1000*k;
      if(Y == total and k >= 0)
  {
      res10000 = i;
      res5000  = j;
      res1000  = N-i-j;
  }
  }
  }
  std::cout << res10000 << " " << res5000 << " " << res1000 << "\n";
}


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

const double pi=acos(-1);

int main(){
    double a,b,c;
    cin>>a>>b>>c;
    c*=pi/180;
    double l=sqrt(a*a+b*b-2*a*b*cos(c));
    double h=b*sin(c);
    double s=a*h/2;
    printf("%.10f\n%.10f\n%.10f\n",s,l+a+b,h);
}


Measured memory_bytes: 3440
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	typedef long long ll;
	const int N = 3e3 + 10;
	int C[N][N], S[N][N], P, n;
	int power(int a, int b, const int P)
	{
		int ans = 1;
		while (b)
		{
			if (b & 1)
				ans = (ll)ans * a % P;
			a = (ll)a * a % P;
			b >>= 1;
		}
		return ans;
	}
	void init()
	{
		S[0][0] = 1;
		for (int i = 0; i < N; i++)
		{
			C[i][0] = 1;
			for (int j = 1; j <= i; j++)
			{
				C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
				S[i][j] = ((ll)j * S[i - 1][j] + S[i - 1][j - 1]) % P;
			}
		}
	}
	int work()
	{
		read(n), read(P);
		init();
		int ans = 0;
		for (int i = 0; i <= n; i++)
		{
			int pow = power(2, n - i, P), sum = 0;
			for (int j = 0, tmp = 1; j <= i; j++, tmp = (ll)tmp * pow % P)
				sum = (sum + (ll)S[i + 1][j + 1] * tmp) % P;
			ans = (ans + (ll)sum * 
					C[n][i] % P * ll(i & 1 ? P - 1 : 1) % P * power(2, power(2, n - i, P - 1), P) % P) % P;
		}
		write(ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 56884
#include<iostream>
#include<sstream>
#include<algorithm>
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();}
int main()
{
  string n;
  for(;cin>>n,n!="0000";)
    {
      int cnt=0;
      while(n!="6174")
	{
	  string s=n;
	  string l=n;
	  sort(s.begin(),s.end());
	  sort(l.begin(),l.end(),greater<char>());
	  n=toString(toInt(l)-toInt(s));
	  while(n.size()<4)
	    n="0"+n;
	  if(s==l)
	    {
	      cnt=-1;
	      break;
	    }  
	  cnt++;  
	}
      if(cnt>=0)
	cout<<cnt<<endl;
      else 
	cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long h;
	cin >> h;
	long long res=0;
	for(long long i=1; i<=h; i*=2){
		res+=i;
	}
	cout << res;
}
// 1 con 9
// 2 con 4
// 4 con 2
// 8 con 1 

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

int main() {
	//input
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	//calculation
	long double theta = (11 * M - 60 * H) * M_PI / 360.0;


	long double output = A * A + B * B - 2.0 * A * B * cos(theta);
	output = sqrt(output);
	cout << fixed << setprecision(15) << output << endl;


	return 0;
}


Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

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

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n, int mod) {
    if (n == 0) { return 1 % mod; }
    int x = rui(a, n / 2, mod);
    x *= x; x %= mod;
    if (n % 2 == 1) { x *= a; x %= mod; }
    return x;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vel uni(vel x) {
    if (x.size() == 0) { return x; }
    sor(x);
    int n = x.size();
    vel ans(1, x[0]);
    for (int j = 1; j < n; j++) {
        if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
    }
    x = ans;
    return x;
}
void pr(vel& v) {
    int n = v.size();
    if (n != 0) {
        cout << v[0];
        rep(i, n - 1) {
            cout << " " << v[i + 1];
        }
        cout << endl;
    }
}
signed main() {
    int n, k; cin >> n >> k;
    vel h(n);
    rep(i, n) { cin >> h[i]; }
    vel all = h; all.push_back(0); sor(all);
    rep(i, n) {
        h[i] = lower_bound(all.begin(), all.end(),h[i])-all.begin();
    }
    int inf = 1000000000;
    inf *= (n + n);
    V<vvel> dp(n+1, vvel(k + 2, vel(n + 1,inf)));//場所、回数、高さ
    dp[0][0][0] = 0;
    rep(i, n) {
        rep(j, k + 1) {
            rep(he, n + 1) {
                mmin(dp[i + 1][j][h[i]], dp[i][j][he] + all[h[i]] - min(all[h[i]], all[he]));
                mmin(dp[i + 1][j + 1][he], dp[i][j][he]);
            }
        }
    }
    int ans = inf;
    rep(j, k + 1) {
        rep(he, n + 1) {
            mmin(ans, dp[n][j][he]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 218752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int A, B, C;
  A = P+Q;
  B = Q+R;
  C = R+P;
  if (A>=B){
    if (B>=C){
      cout << C << endl;
    }
    else if (C>B){
      cout << B << endl;
    }
  }
  if (B>A){
    if (A>=C){
      cout << C << endl;
    }
    if (C>A){
      cout << A << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    string s;
    cin >> s;
    int ans = s.size();
    for(int i=1; i<s.size(); i++){
        if(s[i] == s[i-1]){
            ans--;
            i+=2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
long long num[200005];
bool used[200005]={0};
queue<long long> path;
vector<long long> ans;
int main(){
	long long i,n,k,now=1;
	scanf("%lld%lld",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%lld",&num[i]);
	while(!used[now]){
		used[now]=1;
		path.push(now);
		now=num[now];
	}
	long long temp=0;
	while(path.front()!=now){
		temp++;
		ans.emplace_back(path.front());
		path.pop();
	}
	if(k<=temp-1){
		printf("%lld\n",ans[k]);
		return 0;
	}
	k-=temp-1;
	k=(k-1)%path.size();
	for(i=0;i<k;i++)
		path.pop();
	printf("%lld\n",path.front());
}


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

int a[100001];


int main(){
    int n,q;
    
    int b,c;
    ll sum=0;
    cin>>n;
    int temp;
    for(int i=0;i<n;++i){
        cin>>temp;
        sum=sum+temp;
        a[temp]++;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        ll count=a[b];
        sum = sum-(count*b);
        a[b]=0;
        a[c]=a[c]+count;
        sum = sum+(count*c);
        cout<<sum<<endl;
    }
    
    
    return 0;
}

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

int main() {
	long long int n;
	cin>>n;
	long int ans=0;
	for(long long int i=2;i*i<=n;i++)
	{
	    if(n%i==0)
	    {
	        long long int temp=0;
	        while(n%i==0)
	        {
	            temp++;
	            n/=i;
	        }
	        long long int j,t1=0;
	        for(j=1;j<=temp;j++)
	        {
	            if((j*(j+1))/2 <= temp)
	            t1=max(j,t1);
	            else
	            break;
	        }
	        ans+=t1;
	    }
	}
	if(n>1)
	ans++;
	cout<<ans<<endl;
	return 0;
}

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

int a[2010], b[2010][2010];
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);

    long n, x; cin>>n>>x;
    for(int i=0; i<n; ++i) cin>>a[i];

    for(int i=0; i<n; ++i) {
        b[i][0]=a[i];
        for(int k=1; k<n; ++k)
            b[i][k]=min(b[i][k-1], a[(i-k+n)%n]);
    }

    long res=1L<<62;
    for(int k=0; k<n; ++k) {
        long t=0;
        for(int i=0; i<n; ++i)
            t+=b[i][k];
        res=min(res, t+k*x);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 16000