akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string S; cin >> S;
  if(S[2]==S[3] && S[4]==S[5]) Yes
  else No
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a+b > c+d) {
        printf("Left\n");
    } else if (a+b < c+d) {
        printf("Right\n");
    } else {
        printf("Balanced\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int toInt(string s) { return atoi(s.c_str()); }

bool solve(string s, string t) {
  
  if(s[0] == '0') return 0;
  if(t[0] == '0') return 0;
  
  int a = toInt(s);
  int b = toInt(t);
  
  if(a > b) return 0;
  if((a + b) % 2) return 0;
  
  return 1;
}

int main() {
  
  string a; cin >> a;
  
  int const N = a.size();
  int ans = 0;
  for(int i=0; i<N; i++) {
    ans += solve(a.substr(0, i), a.substr(i));
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1204
import java.io.BufferedReader;
        import java.io.IOException;
        import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String firstLine = br.readLine();
        int N = Integer.parseInt(firstLine);

        String secondLine = br.readLine();
        String[] secondLineArray = secondLine.split(" ");

        int[] result = new int[secondLineArray.length];
        for(int i = 0; i < secondLineArray.length; i++){
            result[Integer.parseInt(secondLineArray[i])-1] = i + 1;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(result[0]);
        for(int i = 1; i < result.length; i++){
            sb.append(" ").append(result[i]);
        }
        System.out.print(sb);
    }
}

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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll n;
    cin>>n;
    set<ll>s;
    ll a;
    for(int i=1;i<=n;i++){
        cin>>a;
        s.insert(a);
    }
    cout<<s.size();
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <functional>

using namespace std;
const int INT_INF = 500000000;
const long long LL_INF = (long long)pow(10, 18);
typedef long long ll;

ll N, C;
ll x[100004] = {0};
ll v[100004] = {0};
ll dp1[100004] = {0};
ll dp2[100004] = {0};
ll dp3[100004] = {0};
ll dp4[100004] = {0};

int main() {
   cin >> N >> C;
   for (int i=0; i < N; i++) {
      cin >> x[i] >> v[i];
   }
   ll v_0toN = 0;
   ll v_Nto0 = 0;
   for (int i=0; i<N; i++) {
      v_0toN += v[i];
      v_Nto0 += v[N-i-1];
      if (dp1[i] >= v_0toN - x[i]) {
	 dp1[i+1] = dp1[i];
	 dp3[i+1] = dp3[i];
      } else {
	 dp1[i+1] = v_0toN - x[i];
	 dp3[i+1] = v_0toN - 2*x[i];
      }
      ll k = v_Nto0 - (C - x[N-i-1]);
      if (dp2[N-i+1] < k) {
	 dp2[N-i] = k;
	 dp4[N-i] = v_Nto0 - 2 * (C - x[N-i-1]);
      } else {
	 dp2[N-i] = dp2[N-i+1];
	 dp4[N-i] = dp4[N-i+1];
      }
      //cout << "i:" << i << " dp1: " << dp1[i] << " dp2: " << dp2[i] << endl;
     //cout << "i:" << i << " dp3: " << dp3[i] << " dp4: " << dp4[i] << endl;
   }
   ll a = 0;
   ll b = 0;
   for (int i=0; i<=N; i++) {
      //cout << "i:" << i << " dp1: " << dp1[i] << " dp2: " << dp2[i] << endl;
     // cout << "i:" << i << " dp3: " << dp3[i] << " dp4: " << dp4[i] << endl;
      a = max(dp4[i+1] + dp1[i], a);
      b = max(dp3[i] + dp2[i+1] , b);
   }
   //cout << a << " " << b << endl;
   cout << max(a, b) << endl;

   return 0;
}


Measured memory_bytes: 4992
(stdin => {
  // Define Function

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')

  const a = parseInt(inputs[0].split(' ')[0], 10)
  const b = parseInt(inputs[0].split(' ')[1], 10)
  const c = parseInt(inputs[0].split(' ')[2], 10)

  const Less1 = (a, b) => a < b
  const less2 = (b, c) => b < c
  const com = (x, y) => {
    return (x && y) ? 'Yes' : 'No'
  }

  console.log(com(Less1(a, b), less2(b, c)))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 15104
a1, b1=map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

listR = [a1, b1, a2, b2, a3, b3]
listR.sort()

flag=0
if 1 in listR and 2 in listR and  3 in listR and 4 in listR:
    listD=[]
    bef=0
    count=0
    index=0
    while index < len(listR):
        if index==0:
            bef=listR[index]
            count=1
        else:
            if listR[index]!=bef:
                if count!=1 and count!=2:
                    print("NO")
                    flag=1
                    break
                else:
                    if count==2:
                        listD.append(bef)
                    bef=listR[index]
                    count=1
            else:
                count+=1
        index+=1
    if count != 1 and count != 2 and flag==0:
        print("NO")
        flag = 1
    else:
        if count==2:
            listD.append(bef)
    if len(listD) == 2 and flag == 0:
        print("YES")
    else:
        if flag==0:
            print("NO")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
//const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int N;
double xs[11];
double ys[11];
double ls[11];

double check2(double X,double Y){
  double res=1e+10;
  for(int i=0;i<N;i++)
    res=min(res,(ls[i]*ls[i]-pow(X-xs[i],2)-pow(Y-ys[i],2)));
  //if(res>EPS)return sqrt(res);
  //rturn 0;
  return res;
}

double check(double X){
  double initUb=-1;
  double initLb=200;
  for(int i=0;i<N;i++){
    initUb=max(initUb,ys[i]);
    initLb=min(initLb,ys[i]);
  }
  double ub=initUb;
  double lb=initLb;
  for(int ite=0;ite<200;ite++){
    double mid1=(ub-lb)/3+lb;
    double mid2=2*(ub-lb)/3+lb;
    if(check2(X,mid1)<check2(X,mid2))lb=mid1;
    else ub=mid2;
  }
  return check2(X,ub);
}

int main(){

  while(cin>>N&&N){
    double initUb=-1;
    double initLb=200;
    for(int i=0;i<N;i++){
      cin>>xs[i]>>ys[i]>>ls[i];
      initUb=max(initUb,xs[i]);
      initLb=min(initLb,xs[i]);
    }
    double ub=initUb;
    double lb=initLb;
    for(int ite=0;ite<200;ite++){
      double mid1=(ub-lb)/3+lb;
      double mid2=2*(ub-lb)/3+lb;
      if(check(mid1)<check(mid2))lb=mid1;
      else ub=mid2;
    }
    double res=check(ub);
    printf("%.10f\n",sqrt(res));
  }
  return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long a,b,c,d;
vector<long long>memo;
map<long long,long long>mp;

long long dist(long long n){

    if(n==0)return 0;

    if(n==1)return d;

    if(mp.find(n)!=mp.end())return mp[n];

    long long ret=n*d;
    if(ret<0)ret=LLONG_MAX;

    ret=min(ret,d*abs(n-(long long)floor((long double)n/5)*5)+(long long)c+(long long)dist(floor((long double)n/5)));
    ret=min(ret,d*abs(n-(long long)ceil((long double)n/5)*5)+(long long)c+(long long)dist(ceil((long double)n/5)));
    
    ret=min(ret,d*abs(n-(long long)floor((long double)n/3)*3)+(long long)b+(long long)dist(floor((long double)n/3)));
    ret=min(ret,d*abs(n-(long long)ceil((long double)n/3)*3)+(long long)b+(long long)dist(ceil((long double)n/3)));

    ret=min(ret,d*abs(n-(long long)floor((long double)n/2)*2)+(long long)a+(long long)dist(floor((long double)n/2)));
    ret=min(ret,d*abs(n-(long long)ceil((long double)n/2)*2)+(long long)a+(long long)dist(ceil((long double)n/2)));
    
    mp[n]=ret;
    return ret;

}


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

    rep(_,t){

        
        long long n;
        cin>>n>>a>>b>>c>>d;

        cout<<dist(n)<<endl;
        mp.clear();
    }
    return 0;

}
/*


*/


Measured memory_bytes: 4424
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();

		String regex = "hi";
		Pattern pt =Pattern.compile(regex);
		Matcher matcher = null;

		if (string.length() < 2 || string.length() % 2 == 1) {
			System.out.println("No");
		}else {
			for (int i = 0; i < string.length(); i+=2) {
				matcher = pt.matcher(string.substring(i, i + 2));
				if (matcher.find() == false) {
					System.out.println("No");
					break;
				}
				if (i == string.length() - 2) {
					System.out.println("Yes");
				}
			}
		}
	}
}

Measured memory_bytes: 35824
#include <bits/stdc++.h>
using namespace std;
bool T=false;
int main(int argc,char *argv[]){
    int N,ans;cin>>N;
    for (int i = 1; i < 11; i++)
    {
        if(1000*i>=N){
            ans=1000*i-N;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a*c<=b)
    {
        printf("%d\n",c);
    }
    else
    {
        printf("%d\n",b/a);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int sum=0;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    if (x<=K-x){
      sum+=x;
    }
    if (x>K-x){
      sum+=(K-x);
    }
  }
  cout << sum*2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 98765432198765432
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int a[100001];
map<int,int> M;
inline ll res(int x)
{
	return 1LL*x*(x-1)/2;
}
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	M[0]++;
	fup(i,1,n,1)
	{
		scanf("%d",a+i);
		a[i]=(a[i-1]+a[i])%m;
		M[a[i]]++;
	}
	ll ans=0;
	for(auto it=M.begin();it!=M.end();it++)
	{
		ans+=res(it->Y);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3584
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

Falling down is an accident, Staying down is a choice.

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

vvll C(2000+5,vll(2000+5));

void construct()
{
	ll i, j,n=2001,k=2001; 
  
    // Caculate value of Binomial Coefficient 
    // in bottom up manner 
    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            // Base Cases 
            if (j == 0 || j == i) 
                C[i][j] = 1; 
  
            // Calculate value using previously 
            // stored values 
            else
                C[i][j] = (C[i - 1][j - 1]%mod + 
                          C[i - 1][j]%mod)%mod; 
        } 
    }
}

int main()
{
    io;
    
    ll s,ans=0;
    cin>>s;
    
    construct();
    
    for(ll i=1;s-2*i-1>=0;i++)
    {
    	ans=(ans%mod+C[s-2*i-1][i-1]%mod)%mod;
    }
    
    cout<<ans;
    
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<pair<long,int>> H(N);
  for(int i=0; i<N; i++){
    cin >> H[i].first;
    H[i].second=1;
  }
  
  bool a=1;
  for(int i=0; i<N-1; i++){
    if(H[i].first>H[i+1].first+1){
      a=0;
    }
    else if(H[i].first==H[i+1].first+1&&H[i].second){
      H[i].first--;
      H[i].second--;
    }
    else if(H[i].first<H[i+1].first){
      H[i+1].first--;
      H[i+1].second--;
    }
  }
  for(int i=0; i<N-1; i++){
    if(H[i].first>H[i+1].first){
      a=0;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 36

typedef struct {
  char suit;
  int value;
} Data;

int judge(Data *, Data *,int);
void bubbleSort(Data *, int);
void selectionSort(Data *, int);

int main(){
  int i,k,N;
  Data C1[MAX],C2[MAX];

  scanf("%d",&N);

  for(i = 0;i < N;i++){
    scanf(" %c%d",&C1[i].suit,&C1[i].value);
  }
  
  for(i = 0;i < N;i++){
    C2[i] = C1[i];
  }

  bubbleSort(C1,N);
  selectionSort(C2,N);

  if(judge(C1,C2,N)){
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }
  
  return 0;
}

int judge(Data C[], Data D[], int N){
  int i;
  
  for(i = 0;i < N;i++){
    if(C[i].suit != D[i].suit || C[i].value != D[i].value){
      return 1;
    }
  }
  return 0;
}

void bubbleSort(Data C[], int N){
  int i,j;
  Data a;

  for(i = 0;i < N;i++){
    for(j = N-1;j >= i+1;j--){
      if(C[j].value < C[j-1].value){
	a = C[j];
	C[j] = C[j-1];
	C[j-1]  = a;
      }
    }
  }
  for(i = 0;i < N;i++){
    printf("%c%c",C[i].suit,C[i].value+48);
    if(i == N-1)break;
    printf(" ");
  }
  printf("\nStable\n");
}

void selectionSort(Data C[], int N){
  int i,j,min;
  Data a; 

  for(i = 0;i < N;i++){
    min = i;
    for(j = i;j < N;j++){
      if(C[j].value < C[min].value){
	min = j;
      }
    }
    a = C[i];
    C[i] = C[min];
    C[min] = a;
  }
  for(i = 0;i < N;i++){
    printf("%c%c",C[i].suit,C[i].value+48);
    if(i == N-1)break;
    printf(" ");
  }
  printf("\n");
}



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

int main(){

    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(i * 500 + j * 100 + k * 50 == X) ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

void dfs(vec<ll>& ans, const vvec<int>& edges, const vec<ll>& adds, vec<bool>& reached, int current, ll counter)
{
    if (reached[current])
        return;

    reached[current] = true;
    counter += adds[current];
    ans[current] += counter;

    for (auto e : edges[current])
    {
        dfs(ans, edges, adds, reached, e, counter);
    }
}

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n, q;
    cin >> n >> q;

    vvec<int> edges(n);
    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vec<ll> adds(n);

    for (int i = 0; i < q; ++i)
    {
        int p, x;
        cin >> p >> x;
        --p;
        adds[p] += x;
    }
    
    vec<ll> ans(n);
    vec<bool> reached(n);

    dfs(ans, edges, adds, reached, 0, 0);

    for (int i = 0; i < n; ++i)
    {
        if (i != 0)
            cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 32128
import java.io.*;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{
		//
		int[] data = new int[10001];
		Scanner input = new Scanner(System.in);
		for(int i=0; i < 10001; i++){
			String str = input.nextLine();
			data[i] = Integer.parseInt(str);
			if( data[i] == 0){
				break;
			}
		}
		
		
		
		for(int i=0; i < 10001; i++){
			if( data[i] == 0){
				break;
			}
			System.out.println("Case "+ (i+1) + ": " + data[i]);
		}
		//
	}
}

Measured memory_bytes: 59460
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var ret = new List<int>();
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var cx = 0;
        for (int i = 0; i < sL; i++) cx += int.Parse(s[i].ToString());
        var count = 0;
        for (int i = 0; i < sL; i++)
        {
            var w = int.Parse(s[i].ToString());
            if (w != '9' && w != '0')
                if (i == 0) { count =w -1; break; }
                else if (i == sL - 1) { count = Math.Max(8, w); break; }
                else { count = Math.Max(8, w - 1); break; }
            if (w == '0') { count = 8; break; }
        }
        var rett = Math.Max(count + (sL - 1) * 9, cx);
        Console.WriteLine(rett);
        }
    }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    string S; cin >> S;

    
    vector<int> blacks(N+1,0);
    vector<int> whites(N+1,0);
    rep(i,N){
        int black = 0;
        if (S[i] == '#') black++;
        blacks[i+1] = blacks[i] + black;
        whites[i+1] = whites[i] + (1-black);
    }
    
    // iより前を白、i以降を黒にする。
    int ans = 100000000;
    rep(i,N+1){
        int black_count = blacks[i];
        int white_count = whites[N] - whites[i];

        ans = min(ans, black_count+white_count);
    }
    
    cout << ans << endl;
}

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

const int MAXN = 55;
const int MAXM = 500;

struct Edge
{
    int to,next;
}edge[MAXM];
int head[MAXN],tot;
int Dfn[MAXN],Low[MAXN];
int Index,res;

void addedge(int u, int v)
{
    edge[tot].to = v;
    edge[tot].next = head[u];
    head[u] = tot++;
}

void Tarjan(int u, int fa)
{
    Dfn[u] = Low[u] = ++Index;
    for(int i = head[u]; i != -1; i = edge[i].next)
    {
        int v = edge[i].to;
        if(!Dfn[v])
        {
            Tarjan(v,u);
            Low[u] = min(Low[u],Low[v]);
            if(Low[v] > Dfn[u])
                ++res;
        }
        else if(v != fa)
            Low[u] = min(Low[u],Dfn[v]);
    }
}

void solve(int n)
{
    Index = res = 0;
    memset(Dfn,0,sizeof(Dfn));
    memset(Low,0,sizeof(Low));
    Tarjan(1,-1);
    printf("%d\n",res);
}

int main()
{
    int n,m,u,v;
    memset(head,-1,sizeof(head));
    tot = 0;
    scanf("%d %d",&n,&m);
    for(int i = 0; i < m; ++i)
    {
        scanf("%d %d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    solve(n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(0);

    int n,m; cin >> n >> m;
    int res=0;
    int time=m*1900+(n-m)*100;
    cout<<time*pow(2,m)<<endl;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n; cin >> n;
  int a,b,c; cin >> a >> b >> c;
  rep(i,1,n){
    int x,y,z; cin >> x >> y >> z;
    int aa = x+max(b,c), bb = y+max(a,c), cc = z+max(a,b);
    a = aa; b = bb; c = cc;
  }
  cout << max(a, max(b, c)) << "\n";
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	SORT(a);
	vector<ll> b(n);
	// > < > < > <で入れていくのと < > < > で入れて行くのをやる。
	int left = 0 , right = n - 1;
	rep(i,n){
		if(i%2==0){
			b[i] = a[left++];
		} else {
			b[i] = a[right--];
		}
	}
	ll ans1 = 0 ;
	rep(i,n-1){
		ans1 +=  abs(b[i] - b[i+1]);
	}
	ans1 = max(ans1,ans1-(abs(b[n-1]-b[n-2]))+(abs(b[n-1] - b[0])));

	left = 0 , right = n - 1;
	rep(i,n){
		if(i%2==0){
			b[i] = a[right--];
		} else {
			b[i] = a[left++];
		}
	}
	ll ans2 = 0 ;
	rep(i,n-1){
		ans2 += abs(b[i] - b[i+1]);
	}
	ans2 = max(ans2,ans2-(abs(b[n-1]-b[n-2]))+(abs(b[n-1] - b[0]))) ;
	cout << max(ans1,ans2) << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    String s = scan.next();
	    scan.close();

	    int arr[]=new int[s.length()];
	    for(int i=0;i<s.length();i++) {
	    	arr[i]=Character.getNumericValue(s.charAt(i));
	    }
	    int cnt=0;
	    for(int i=1;i<s.length();i++) {
	    	if(arr[i-1]==arr[i]) {
	    		arr[i] = (arr[i]+1)%2;
	    		cnt++;
	    	}
	    }

	    System.out.println(cnt);

	}

}

Measured memory_bytes: 27348
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Data.Array.IArray
import           Data.Array.IO
import           Data.Array.MArray
import qualified Data.IntMap.Strict    as M
import           Data.List             (unfoldr)
import           Data.Maybe

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

--

type PQ = M.IntMap [Int]

pqsingleton :: (Int, Int) -> PQ
pqsingleton (k, v) = M.singleton v [k]

pqpush :: (Int, Int) -> PQ -> PQ
pqpush (k, v) pq = M.insertWith (++) v [k] pq

pqpushList :: [(Int, Int)] -> PQ -> PQ
pqpushList xs pq = foldr pqpush pq xs

pqextractMin :: PQ -> Maybe ((Int, Int), PQ)
pqextractMin pq
    | M.null pq  = Nothing
    | null as   = Just ((a, k), pq')
    | otherwise = Just ((a, k), M.insert k as pq')
  where
    Just ((k, a:as), pq') = M.minViewWithKey pq

--

dijk :: Array Int [(Int, Int)] -- adjacent list
     -> IOUArray Int Bool      -- color
     -> IOUArray Int Int       -- distance
     -> IO ()
dijk graph color dist = go (pqsingleton (0, 0))
  where
    go :: PQ -> IO ()
    go !pq = do
        case pqextractMin pq of
            Nothing            -> return ()
            Just ((u, uc), pq') -> do
                writeArray color u False -- Black
                du <- readArray dist u
                if (du < uc)
                    then do
                        go pq'
                    else do
                        vs <- filterM (readArray color . fst) (graph ! u)
                        maybePush <- forM vs $ \(v, mv) -> do
                            dv <- readArray dist v
                            if (du + mv < dv)
                                then do
                                    writeArray dist v (du + mv)
                                    return $ Just (v, du + mv)
                                else do
                                    return $ Nothing
                        go (pqpushList (catMaybes maybePush) pq')

main :: IO ()
main = do
    let f []       = Nothing
        f (i:j:ks) = Just ((i, j), ks)

    n <- readLn
    xss <-
        replicateM n $ do
            (i:_:xs) <- fmap readi . B.words <$> B.getLine
            return (i, unfoldr f xs)

    let graph = array (0, n-1) xss      :: Array Int [(Int, Int)]
    color <- newArray (0, n-1) True     :: IO (IOUArray Int Bool)
    dist  <- newArray (0, n-1) maxBound :: IO (IOUArray Int Int)
    writeArray dist 0 0

    dijk graph color dist

    forM_ [0 .. n-1] $ \i -> do
        v <- readArray dist i
        putStr (show i ++ " ")
        print v



Measured memory_bytes: 131068
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
set<ll> s1,s2,s3;
int main()
{
    ll i,N,M,j,ans=0;
    cin>>N>>M;
    for(i=1;i<=sqrt(N);i++)
    {
        if(N%i==0) { s1.insert(N/i); s1.insert(i); }
    }
    for(i=1;i<=sqrt(M);i++)
    {
        if(M%i==0) { s2.insert(M/i); s2.insert(i); }
    }
    for(auto &k:s1)
    {
        if(s2.find(k)!=s2.end()) { s3.insert(k);}
    }
	for(auto &k:s3)
	{ 
		ll t4=0;
		for(i=2;i<=sqrt(k);i++)
		{
			if(k%i==0) {  t4=1; break;	}	
		}	
		if(t4==0) {  ans++; }
	}
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1152
import java.util.*;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int[] b = A.clone();
		Arrays.parallelSort(b);
		for(int i = 0 ; i< N; i++) {
			if(A[i] == b[N-1]) {
				System.out.println(b[N-2]);
				continue;
			}
			System.out.println(b[N-1]);
		}
		
		sc.close();
	}

}


Measured memory_bytes: 88724
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  ll n,sum=0;
  cin >> n;
  ll b[n-1],a[n];
  for(int i=0;i<n-1;i++){
    cin >> b[i];
  }
  sum+=b[0];
  for(int i=0;i<n-2;i++){
    sum+=min(b[i],b[i+1]);
  }
  sum+=b[n-2];
  cout << sum<<endl;
}


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

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

    int n;
    cin >> n;

    vector<int> a(n), d(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        d[i] = a[i];
    }

    sort(a.begin(), a.end());
    sort(d.begin(), d.end(), greater<int>());
    
    deque<int> dq, dq2;
    dq.push_back(a[0]);
    dq2.push_back(d[0]);
    int a_ptr = 1;
    int d_ptr = 0;
    int a_ptr2 = 0;
    int d_ptr2 = 1;
    for(int i = 0; i < n; ++i){
        dq.push_front(d[d_ptr]);
        dq2.push_front(a[a_ptr2]);
        if(dq.size() == n) break;
        ++d_ptr;
        ++a_ptr2;
        dq.push_back(d[d_ptr]);
        dq2.push_back(a[a_ptr2]);
        if(dq.size() == n) break;
        ++d_ptr;
        ++a_ptr2;
        dq.push_front(a[a_ptr]);
        dq2.push_front(d[d_ptr2]);
        if(dq.size() == n) break;
        ++a_ptr;
        ++d_ptr2;
        dq.push_back(a[a_ptr]);
        dq2.push_back(d[d_ptr2]);
        if(dq.size() == n) break;
        ++a_ptr;
        ++d_ptr2;
    }

    long long res = 0;
    long long res2 = 0;
    int prev = dq[0];
    int prev2 = dq2[0];
    for(int i = 1; i < n; ++i){
        int now = dq[i];
        int now2 = dq2[i];
        res += abs(now - prev);
        res2 += abs(now2 - prev2);

        prev = now;
        prev2 = now2;
    }



    cout << max(res, res2) << endl;

    return 0;
}

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

int main() {
  int N;
  char c;
  int a=0; 
  
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> c;
    if(c == 'Y') {
      a=1;
      break;
    }
  }
  if(a) cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

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

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;

  REP(i,A){
    if('0'  > S[i] || S[i] > '9' ){
      cout << "No" << endl;
      exit(0);
    }
  }
  if(S[A] != '-'){
    cout << "No" << endl;
    exit(0);
  }

  FOR(i,A+1,A+B+1){
    if('0'  > S[i] || S[i] > '9' ){
      cout << "No" << endl;
      exit(0);
    }
  }
  cout <<"Yes" << endl;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

l = []
for i, v in enumerate(a):
    if "#" not in v:
        l.append(i)
for i in l[::-1]:
    a.pop(i)

a = list(zip(*a))
l = []
for i, v in enumerate(a):
    if "#" not in v:
        l.append(i)
for i in l[::-1]:
    a.pop(i)

a = list(zip(*a))
for i in a:
    print("".join(i))

Measured memory_bytes: 38256
#include<stdio.h>
int main()
{
	int n,m,i,r,x;
	while(scanf("%d%d",&n,&m),n)
	{
		char s[1000003]="";
		scanf("%s",s);
		for(r=i=0;s[i];++i)
		{
			if(s[i]=='I')
			{
				for(x=0;s[i+2];i+=2)
					if(s[i+1]=='O'&&s[i+2]=='I')++x;
					else break;
				if(x>=n)r+=x-n+1;

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

Measured memory_bytes: 0
#include <stdio.h>

int main(){
	int X,A,B;

	scanf("%d", &X);
	scanf("%d", &A);
	scanf("%d", &B);

	if(B - A <= 0){
		printf("delicious\n");
	}else if(B - A <= X && B - A > 0){
		printf("safe\n");
	}else if(B - A > X){
		printf("dangerous\n");
	}

	return 0;
}

Measured memory_bytes: 128
a=[]
b=[]
for _ in range(3):
    a.append(list(map(int,input().split())))
N=int(input())
for _ in range(N):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==a[k][j]:
                a[k][j]=0
if (a[0][0]==0 and a[0][1]==0 and a[0][2]==0)or(a[1][0]==0 and a[1][1]==0 and a[1][2]==0) or (a[2][0]==0 and a[2][1]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
    print("Yes")
else:
    print("No")

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

using namespace std;

int main()
{
  vector< int > poll;
  poll.push_back(1);
  for(int i = 2; i <= 999; i++) {
    poll.push_back(poll.back() + i);
  }

  int a, b;
  cin >> a >> b;

  for(int i = 0; i < poll.size() - 1; i++) {
    if(poll[i] - a == poll[i + 1] - b) {
      cout << poll[i] - a << endl;
    }
  }

  return 0;
}


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

using namespace std;

int sqroot(int n) {
	int ans = 0;
	while (true) {
		if (ans*ans > n) {
			break;
		}
		else {
			ans++;
		}
	}
	return ans-1;
}

int ketasuu(int m) {
	int ans2 = 0;
	while (m > 0) {
		ans2++;
		m /= 10;
	}
	return ans2;
}

int main() {
	int a, b;
	cin >> a >> b;
	int c = ketasuu(b);
	for (int i = 0; i < c; i++) {
		a = 10 * a;
	}
	int d = a + b;
	if (sqroot(d)*sqroot(d) == d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
function Main(_input) {
    const lines = _input.split("\n");
    const first = lines[0].split(' ');
    const n = parseInt(first[0], 10);
    const k = parseInt(first[1], 10);
    const arr = [];

    for (let i = 0; i < n; i++) {
        arr[i] = 0;
    }

    for (let i = 0; i < k; i++) {
        const num = lines[i * 2 + 2].split(' ');
        for (let j = 0; j < num.length; j++) {
            const p = parseInt(num[j],10) - 1;
            if (!arr[p]) {
                arr[p] = 1;
            } else {
                arr[p]++;
            }
        }
    }

    console.log(arr.filter((val) => {
        return val === 0;
    }).length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    REP(i, n){
        cin >> x[i] >> y[i] >> p[i];
    }

    vector<vector<ll>> x2d(1LL << n, vector<ll>(n)), y2d(1LL << n, vector<ll>(n));
    REP(i, (1LL << n)){
        vector<ll> xs, ys;
        REP(j, n){
            if((i >> j) & 1){
                xs.push_back(x.at(j));
                ys.push_back(y.at(j));
            }
        }
        REP(j, n){
            {
                ll dx = abs(x.at(j));
                for(ll x2 : xs){ dx = min(dx, abs(x.at(j) - x2)); }
                x2d.at(i).at(j) = dx;
            }

            {
                ll dy = abs(y.at(j));
                for(ll y2 : ys){ dy = min(dy, abs(y.at(j) - y2)); }
                y2d.at(i).at(j) = dy;
            }
        }
    }

    ll ub = 1;
    REP(i, n){ ub *= 3; }

    vector<ll> ans(n + 1, numeric_limits<ll>::max());

    REP(i, ub){
        ll ix = 0, iy = 0, k = 0;
        {
            ll m = i;
            REP(j, n){
                const ll l = m % 3;
                if(l == 1){
                    ix += (1LL << j);
                    k++;
                }else if(l == 2){
                    iy += (1LL << j);
                    k++;
                }
                m /= 3;
            }
        }

        ll s = 0;
        const auto& dx = x2d.at(ix), dy = y2d.at(iy);
        REP(j, n){
            ll d = min(dx.at(j), dy.at(j));
            s += p.at(j) * d;
        }

        ans.at(k) = min(ans.at(k), s);
    }

    for(auto ai : ans){
        cout << ai << endl;
    }
    return 0;
}


Measured memory_bytes: 12952
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

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

const double EPS = 1e-10;
const int INF = 1e7;

int main(){
  int a, b, c, k;
  scanf("%d%d%d%d", &a, &b, &c, &k);
  int max_val = max(a, max(b, c));
  int sum = a + b + c;
  sum = sum - max_val + max_val * pow(2, k);
  std::cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<int> D(N); cin >> D;
    vector<int> cnt(13);

    for(auto d : D) ++cnt[d];

    int ans = -1;

    if(cnt[0] >= 1) ans = 0;
    if(cnt[12] >= 2) ans = 0;
    FORE(i,1,11) if(cnt[i] >= 3) ans = 0;

    if(ans==-1){
      vector<int> t(24);
      t[0] = 1;

      if(cnt[12]) t[12] = 1;

      FORE(i,1,11){
	if(cnt[i] == 2){
	  t[i] = 1;
	  t[24-i] = 1;
	}
      }

      REP(i,1<<11){
	vector<int> a(t);
        FORE(j,1,11){
	  if(cnt[j]==1){
	    if((i>>(j-1))&1) a[j] = 1;
	    else a[24-j] = 1;
	  }
	}

	int temp = 24;
	REP(x,24){
	  REP(y,24){
	    if(x!=y and a[x] and a[y]){
	      chmin(temp, min(abs(x-y), (x-y+24)%24));
	    }
	  }
	}
	
	chmax(ans, temp);
      }
    }

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


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



int main()
{

	int n;
	cin>>n;
	vector<int>v;
	set<int>s;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
		s.insert(x);

	}
	sort(v.begin(), v.end());
	int m = v[v.size()-1];
	/*if(m%2!=0 && s.find(m-1)!=s.end())
		m--;*/
	int lo = 0, hi = n+1,mid=0;
	while(lo<hi-1)
	{
		mid = (lo+hi)/2;
		if(v[mid]<=m/2)
			lo=mid;
		else
			hi=mid;
	}
	int r1 = v[lo];
       	int r2 = *upper_bound(v.begin(),v.end(),m/2);
	int r = 0;
	if((fabs((double)m/2-r1)>fabs((double)m/2-r2)) && r2 != m)
		r=r2;
	else
		r=r1;
	if(r==m)
		r=v[v.size()-2];
cout<<m<<" "<<r<<"\n";	
	
}


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

int main() {
    int n;
    cin >> n;
    double ar[n];
    
    for(auto &i : ar)
        cin >> i;
        
    sort(ar, ar + n);
    double res = (ar[0] + ar[1]) / 2;
    
    for(int i = 2; i < n; ++i)
        res = (res + ar[i]) / 2;
        
    cout << res;
}

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

template<typename T>
struct segment_tree{
    function<T(T,T)> f = [](T a, T b){return min(a,b);};
    T inf=0;
    vector<T> value;
    int N;
    segment_tree(int n){
        N=1;
        while(N<n)N*=2;
        value.assign(2*N-1,inf);
    }
    segment_tree(int n, function<T(T,T)> func, T t1){
        N=1;
            while(N<n)N*=2;
        value.assign(2*N-1,t1);
        f=func;
        inf=t1;
    }
    ll update(int i){
        ll ans=0;
        i+=N-1;
        ans+=value[i];
        while(i>0){
            i=(i-1)/2;
            ans+=value[i];
        }
        return ans;
    }
    void query(T a,T b,ll n){
        return query(a,b,0,0,N,n);
    }
    void query(T a,T b, int k, int l, int r, ll n){
        if(r<=a || b<=l)return;
        if(a<=l && r<=b){
            value[k]+=n;
        }else{
            query(a,b,2*k+1,l,(l+r)/2,n);
            query(a,b,2*k+2,(l+r)/2,r,n);
        }
    }
    void print(){
        for(int i=0;i<ceil(log2(N))+1;i++){
            for(int j=0;j<(1<<i);j++){
                cout<<value[j+(1<<i)-1]<<((j==(1<<i)-1)?"":",");
            }
            cout<<endl;
        }
    }
};

int main(){
    ll n,q;
    cin>>n>>q;
    segment_tree<ll> tree(n);
    rep(i,q){
        ll com;
        cin>>com;
        if(com==0){
            ll s,t,x;
            cin>>s>>t>>x;
            tree.query(s-1, t, x);
        }else{
            ll i;
            cin>>i;
            cout<<tree.update(i-1)<<endl;;
        }
    }
}



Measured memory_bytes: 4940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b;
  cin >> a >> b;
  print(a * b);
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[100001];
int diff[100001];
int N,M;
int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++) scanf("%d",arr+i);
	sort(arr,arr+M);
	long long sum=0;
	for(int i=0;i+1<M;i++) diff[i]=arr[i+1]-arr[i];
	sort(diff,diff+M-1);
	for(int i=M-2,j=0;i>=0;i--){
		if(j<N-1) j++;
		else sum+=diff[i];
	}
	printf("%lld",sum);
}

Measured memory_bytes: 896
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
    };
    if s == "AAA" || s == "BBB" {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352