akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define y first
#define x second
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1e9;

int my3[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int mx3[8] = {1, -1, 0, 0, -1, 1, 1, -1};
int my2[16] = {-2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1};
int mx2[16] = {-2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2};
int my[4] = {0, 0, 1, -1};
int mx[4] = {1, -1, 0, 0};

int H, W;

int dist(P &a, P &b, vector< vector<int> > &v){
  priority_queue<PP, vector<PP>, greater<PP> > open;
  open.push(PP(0, P(a.y, a.x)));
  vector< vector<int> > closed(H, vector<int>(W, INF));
  while(!open.empty()){
    PP tmp = open.top(); open.pop();
    int s = tmp.first;
    P now = tmp.second;
    if(now == b) return s;
    REP(i, 4){
      int ny = now.y + my[i], nx = now.x + mx[i];
      if(ny >= 0 && nx >= 0 && ny < H && nx < W && v[ny][nx] != INF && closed[ny][nx] > s + v[now.y][now.x]){
        closed[ny][nx] = s + v[now.y][now.x];
        open.push(PP(closed[ny][nx], P(ny, nx)));
      }
    }
  }
  return -1;
}

int solve(vector< vector<int> > &d, int m, P &s, P &g, vector<P> &ms, vector< vector<int> > &v){
  vector< vector<int> > dp((1 << m), vector<int>(m, INF));
  REP(i, m) dp[(1 << i)][i] = dist(s, ms[i], v);
  REP(i, (1 << m)){
    REP(j, m){
      if(dp[i][j] == INF) continue;
      REP(next, m){
        if(((1 << next) & i) != 0) continue;
        int c = d[j][next], n = ((1 << next) | i);
        dp[n][next] = min(dp[n][next], dp[i][j] + c);
      }
    }
  }
  int res = INF;
  REP(i, m) res = min(res, dp[(1 << m) - 1][i] + dist(ms[i], g, v));
  return res;
}

int main() {
  cin >>W >>H;
  vector<string> cv(H);
  REP(i, H) cin >>cv[i];
  vector< vector<int> > v(H, vector<int>(W, 1));
  vector<P> ms;
  P s, g;
  REP(y, H){
    REP(x, W){
      if(cv[y][x] == 'M') ms.push_back(P(y, x));
      if(cv[y][x] == 'S') s = P(y, x);
      if(cv[y][x] == 'G') g = P(y, x);
      if(cv[y][x] != '#') continue;
      v[y][x] = INF;
      REP(i, 8){
        int ny = y + my3[i], nx = x + mx3[i];
        if(ny >= 0 && nx >= 0 && ny < H && nx < W) v[ny][nx] = max(3, v[ny][nx]);
      }
      REP(i, 16){
        int ny = y + my2[i], nx = x + mx2[i];
        if(ny >= 0 && nx >= 0 && ny < H && nx < W) v[ny][nx] = max(2, v[ny][nx]);
      }
    }
  }
  int msl = ms.size();
  vector< vector<int> > d(msl, vector<int>(msl, 0));
  REP(i, msl){
    REP(j, msl) d[i][j] = dist(ms[i], ms[j], v);
  }
  cout <<solve(d, msl, s, g, ms, v) <<endl;
  return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
      cin >> a[i];
  }
  reverse(a.begin(), a.end());
  rep(i, n){
      cout << a[i];
      if (i != n-1) cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    vector<int> a;
    cin >> n;
    for(int i=0;i<n;i++){
        int input;
        cin >> input;
        a.emplace_back(input);
    }
    for(int i = 0;i<n;i++){
        for(int j = 0;j<n;j++){
            vector<int> b = a;
            int tmp = b[i];
            b[i] = b[j];
            b[j] = tmp;
            int k = 0;
            while(b[k] <= b[k+1]){
                if(k==n-2){
                    cout << "YES" << endl;
                    return 0;
                }
                k++;
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
void solve(){
    string a,b;
    cin>>a>>b;
    int za = a.size();
    int zb = b.size();
    int ans = 1e9;
    for(int i=0;i<=za-zb;i++){
        int cnt = 0;
        for(int j=0;j<zb;j++){
            if(b[j]!=a[i+j])cnt++;
        }
        ans = min(ans,cnt);
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			Integer H1 = scanner.nextInt();
			Integer M1 = scanner.nextInt();
			Integer H2 = scanner.nextInt();
			Integer M2 = scanner.nextInt();
			Integer K = scanner.nextInt();

			Integer hour = H2 - H1;
			Integer minute = M2 - M1;
			if (hour < 0) {
				hour = 24 + hour;
			}
			if (minute < 0) {
				hour--;
				minute = 60  + minute;
			}
			Integer totalMinute = hour * 60 + minute;
			System.out.print(totalMinute - K);
		}
	}
}


Measured memory_bytes: 35864
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
void init(vector<bitset<26>> &seg, string S,int n){
    int N=S.size();
    for (int i = 0; i < N; i++)seg[i+n-1].set((int)S[i]-(int)'a');
    for (int i = n-2; i >=0; i--)seg[i]=seg[2*i+1]|seg[2*i+2];
}
void update(vector<bitset<26>> &seg, int x, char c, int n){
    x+=n-1;
    seg[x]=0;seg[x].set((int)c-(int)'a');
    while (x>0)
    {
        x=(x-1)/2;
        seg[x]=seg[2*x+1]|seg[2*x+2];
    }
    
}
bitset<26> query(vector<bitset<26>> &seg,int n, int a, int b,
    int k=0, int l=0, int r=-1){
    if(r<0)r=n;
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return seg[k];
    return query(seg,n,a,b,2*k+1,l,(l+r)/2)|query(seg,n,a,b,2*k+2,(l+r)/2,r);
}
int main() {
    int N,Q;
    string S;
    cin>>N>>S>>Q;
    int n=1; while(n<N) n*=2;
    vector<bitset<26>> seg(2*n-1);
    init(seg,S,n);
    for (int i = 0; i < Q; i++){
        int type;
        cin>>type;
        if(type==1){
            int i;char c;
            cin>>i>>c;
            update(seg,i-1,c,n);
        }else{
            int l,r;
            cin>>l>>r;
            cout<<query(seg,n,l-1,r).count()<<endl;
        }
    }
}

Measured memory_bytes: 9604
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;
typedef long long ll;
const int M = 200000;
// SMAX = 10^14 
struct Rectangle {int hei, ind;};

stack<Rectangle> s;
ll Area(int w, int a[])// 返回值 
{
	while (!s.empty()) s.pop();
	a[w] = 0;
	ll maxs = 0;
	
	for (int i = 0; i <= w; ++i)
	{
		Rectangle cur;
		cur.hei = a[i];
		cur.ind = i;
		
		if (s.empty()) 					s.push(cur);
		else 
		{
			if (s.top().hei < cur.hei) 	s.push(cur);
			else if (s.top().hei > cur.hei)
			{
				int tmp = cur.ind;
				while (!s.empty() && s.top().hei >= cur.hei)
				{
					Rectangle pre = s.top(); s.pop();
					ll area = 1ll * pre.hei * (i - pre.ind);
					maxs = max(maxs, area);
					tmp = pre.ind;					
				}
				cur.ind = tmp;
				s.push(cur);
			}
		}		
	}
	
	return maxs;
}

int main()
{
	int w = 0, a[M] = {0};
	scanf("%d", &w);
	for (int i = 0; i < w; ++i)
		scanf("%d", a+i);
	
	printf("%lld\n", Area(w, a));
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<int> p(n), sp(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        sp[i] = p[i];
    }
    sort(all(sp));

    int num = 0;
    for (int i = 0; i < n; ++i) {
        if (p[i] != sp[i]) num++;
    }
    if (num <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int[] a = new int[3];

      for (int i = 0;i<3 ;i++ ) {
        a[i] = sc.nextInt();
      }
      Arrays.sort(a);

      if(a[2]==a[1]+a[0]){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }

  }
}


Measured memory_bytes: 23764
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    n,m=map(int,input().split())
    a = [int(x) for x in input().split()]
    mod=998244353
    hf=(mod+1)//2
    dp=[0]*(m+1)
    dp[0]=(1<<n)%mod
    for x in a:
        for i in reversed(range(m+1-x)):
            dp[i+x]+=dp[i]*hf
            dp[i+x]%=mod
    print(dp[m])
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 95744
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    j=i%10+(i//10)%10+(i//100)%10+(i//1000)%10+(i//10000)%10+(i/100000)%10
    if a<=j<=b+1:
        ans+=i
print(ans)

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

using namespace std;

using ll = long long;

const int L = 60; 
ll basis[L];

void insert_vec(ll msk) {
    for (int i = L-1; i >= 0; i--) {
        if (!(msk&(1ll<<i))) continue;
        if (!basis[i]) {
            basis[i] = msk; return;
        }
        msk ^= basis[i];
    }
}

void solve() {
    int n; cin >> n;
    vector<long long> a(n);
    ll sum = 0;
    for (auto& x: a) {
        cin >> x;
        sum ^= x;
    }
    for (int i = L-1; i >= 0; i--) {
        if (sum & (1ll<<i)) {
            for (auto& x: a) {
                if (x & (1ll<<i)) x ^= 1ll<<i;
            }
        }
    }
    for (auto& x: a) {
        insert_vec(x);
    }
    ll y = 0;
    for (int i = L-1; i >= 0; i--) {
        if (!basis[i]) continue;
        if (y & (1ll<<i)) continue;
        y ^= basis[i];
    }
    ll res = (y<<1) + sum;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>


using namespace std;
#define INF 1000000005
int main()
{
long long int n,x;
std::cin >> n >> x;
std::vector<long long int> a;
for(long long int i = 0; i < n; i++){
    long long int temp;
    std::cin >> temp;
    a.push_back(temp);
}
std::vector<std::vector<long long int>> small;

std::vector<long long int> smallf;
smallf.push_back(a[0]);
for(long long int i = 1; i < n; i++){
    smallf.push_back(a[i]);
}
small.push_back(smallf);

//int flag = 0;
/*for(int i = 0; i < n; i++){
    a.push_back(a[i]);
}
for(int i = 0; i < n; i++){
    long long int min = a[i];
    for(int j = 1; j < n; j++){
        if(min > a[i + j] + 10 * j){
            min = a[i + j] + 10 * j;
            if(flag < j){
                flag = j;
            }
        }
    }
}*/
for(long long int j = 1; j < n; j++){
    std::vector<long long int> smallt;
    if(small[0][n - j] >= small[j - 1][0]){
        //flag = j;
        smallt.push_back(small[j - 1][0]);
    } else {
        smallt.push_back(small[0][n-j]);
    }
    for(long long int i = 1; i < n; i++){
    long long int k = i - j;
    if(k < 0){
        k += n;
    }
    if(small[0][k] >= small[j - 1][i]){
        //flag = j;
        smallt.push_back(small[j - 1][i]);
    } else {
        smallt.push_back(small[0][k]);
    }
    }
small.push_back(smallt);
}
/*
for(int j = 1; j <= flag; j++){
    if(small[j - 1][0] >=small[j - 1][n - 1]){
        small[j][0] = small[j - 1][n - 1];
    } else {
        small[j][0] = small[j - 1][0];
    }
    for(int i = 1; i < n; i++){
    if(small[j - 1][i] >= small[j - 1][i - 1]){
        small[j][i] = small[j - 1][i - 1];
    } else {
        small[j][i] = small[j - 1][i];
    }
    }
}
*/
long long int sum = 0;
/*int count = 0;
int fsum = 0;
int same = 0;*/
for(int i = 0; i < n; i++){
    sum += small[0][i];
}
for(int i = 1; i < n; i++){
    long long int min = 0;
    for(int j = 0; j < n; j++){
        min += small[i][j];
    }
    min += x * i;
    if(sum > min){
        sum = min;
    }
}
std::cout << sum << std::endl;
return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  string s;
  int k;
  cin>>s>>k;
  vector <string> a;
  for (int i(0);i<s.size();i++){
    for (int j(1);j<=k;j++){
      if (i+j<=s.size()) a.push_back(s.substr(i,j)); 
    }
  }
  // for (int i(0);i<a.size();i++) cout << a[i] << " ";
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  cout << a[k-1] << endl;
  return 0;
}


Measured memory_bytes: 1660
S=int(input())
DP=[0]*(S+11)
mod=10**9+7
DP[0]=1
DP[1]=0
DP[2]=0
DP[3]=1
C=2
for i in range(4,S+1):
  DP[i]=(C-DP[i-1]-DP[i-2])%mod
  C=(C+DP[i])%mod
print(DP[S])


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

#define LL long long int
#define mp make_pair
#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef vector <LL> vll;
typedef pair<LL, LL> iPair;
const int MOD = 1e9+7;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

    LL t = 1;
    LL i,j;
    // cin>>t;
    
    while(t--)
    {
        int n;
        cin>>n;
        vi arr(n-1);
        FOR(i, n-1) cin>>arr[i];
        vi ans(n);
        ans[n-1] = arr[n-2];
        ans[0] = arr[0];
        for(int i = n-2; i> 0; --i)
        {
            ans[i] = min(arr[i], arr[i-1]);
        }
        cout<<accumulate(ans.begin(), ans.end(), 0);

    }

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string str[100010];
    ll ini[5]={};
    int p[10]={0,0,0,0,0,0,1,1,1,2};
    int q[10]={1,1,1,2,2,3,2,2,3,3};
    int r[10]={2,3,4,3,4,4,3,4,4,4};
    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='M')ini[0]++;
        if(s[0]=='A')ini[1]++;
        if(s[0]=='R')ini[2]++;
        if(s[0]=='C')ini[3]++;
        if(s[0]=='H')ini[4]++;
    }
    ll res=0;
    rep(i,10){
        res+=ini[p[i]]*ini[q[i]]*ini[r[i]];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int sum = 0;
for(int i = 1; i <= n ;i++){
 if(i%3 == 0 || i%5 == 0){
   continue;
 }
 else{
   sum += i;
 }
}
cout<<sum<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    string s;
    cin >> s;

    int size = s.size();

    if (size % 2 == 1)
    {
        cout << "No" << endl;
        return (0);
    }

    for (int i = 1; i < size; i += 2)
    {
        if (s[i - 1] == 'h' && s[i] == 'i')
            continue;

        cout << "No" << endl;
        return (0);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

total = [0] * (N + 1)
for i in range(N):
    total[i + 1] = total[i] + A[i]

total_rev = [0] * (N + 1)
for i in range(N):
    total_rev[i] = total[N] - total[i]

ans = 0
for i in range(N - 1):
    ans = (ans + A[i] * total_rev[i + 1]) % m

print(ans)


Measured memory_bytes: 36244
#include<cstdio>
#include<iostream>
#include <algorithm>
#include<cstring>
using namespace std;

typedef long long ll;

int n,m,k,i,tot;
int main()
{
    cin>>n>>m>>k;
    for( i=100;;i--)
    {
        if(n%i==0&&m%i==0)  tot++;
        if(tot==k)  break;
    }
    cout<<i<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
void CountingSort(int[], int,int);

int main() {
	int n;
	int A[2000001];
	int k;
	cin >> n;
	int max = INT_MIN;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (max < A[i]) max = A[i];
	}
	k = max;
	CountingSort(A, k, n);
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i != n - 1) cout << " ";
		else cout << endl;
	}
}

void CountingSort(int A[], int k,int n) {
	int C[10001], B[2000001];
	for (int i = 0; i <= k; i++) {
		C[i] = 0;
	}
	for (int j = 0; j < n; j++) {
		C[A[j]]++;
	}
	for (int i = 1; i <= k; i++) {
		C[i] = C[i] + C[i - 1];
	}
	for (int j = n - 1; j >= 0; j--) {
		B[C[A[j]]-1] = A[j];
		C[A[j]]--;
	}
	for (int i = 0; i < n; i++) {
		A[i] = B[i];
	}

}

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

int main ()
{
    int N;
    int max=0;
    cin >> N;
    int tmp;
    int sum=0;
    for(int i=0;i<N;i++){
        cin >> tmp;
        if(max<tmp)max=tmp;
        sum+=tmp;
    }
    cout<< sum-(int)(max/2) << endl;
}












Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string ans = "";
	rep(i, n) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int x,y,z,n,i,j;
long long l[100005],r[100005];

struct dat{
	int a,b,c;
	
	bool operator < (const dat& T) const{
		return a - b < T.a - T.b;
	}
}a[100005];

priority_queue <pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > b;

int main(){
	scanf("%d%d%d", &x, &y, &z);
	
	n = x + y + z;
	
	for(i = 0; i < n; i++)
	scanf("%d%d%d", &a[i].a, &a[i].b, &a[i].c);
	
	sort(a, a + n);
	
	long long cur = 0;
	
	for(i = 0; i < n; i++){
		if(b.size() < y){
			b.push({a[i].b - a[i].c, i});
			cur += a[i].b;
		}
		else{
			if(b.top().first < a[i].b - a[i].c){
				cur -= a[b.top().second].b;
				cur += a[b.top().second].c;
				b.pop();
				cur += a[i].b;
				b.push({a[i].b - a[i].c, i});
			}
			else
			cur += a[i].c;
		}
		l[i] = cur;
	}
	
	while(b.size()) b.pop();
	cur = 0;
	
	for(i = n - 1; i >= 0; i--){
		if(b.size() < x){
			b.push({a[i].a - a[i].c, i});
			cur += a[i].a;
		}
		else{
			if(b.top().first < a[i].a - a[i].c){
				cur -= a[b.top().second].a;
				cur += a[b.top().second].c;
				b.pop();
				cur += a[i].a;
				b.push({a[i].a - a[i].c, i});
			}
			else
			cur += a[i].c;
		}
		
		r[i] = cur;
	}
	
	long long res = 0;
	
	for(i = y - 1; i < n - x; i++)
	res = max(res, l[i] + r[i + 1]);
	
	printf("%lld\n", res);
}


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

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

  if (A > B || (N == 1 && A != B)) {
    cout << 0 << endl;
    return 0;
  }

  cout << B * (N - 2) - A * (N - 2) + 1 << endl;

  return 0;
}


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

const int mod = 1e9 + 7;

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];

        a[i] = std::abs(a[i]);
    }

    std::sort(a.begin(), a.end());

    std::cout << a[n - 1] - a[0] << std::endl;
}


Measured memory_bytes: 256
//Jai Shree Krishna
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-8
void display(vector<int> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
ll dx[8] = {0,1,0,-1,1,1,-1,-1};
ll dy[8] = {1,0,-1,0,1,-1,1,-1};



int n,p;


long long C(long long int n,long long  int r) {
    if(r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
    long long int ans = 1LL;
    long long int i;
    
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    
    return ans;
}
ll expo(ll base,ll to)
{
    ll ans = 1LL;
    while (to--) {
        ans*=base;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>p;
   // cout<<dp[0][1]<<endl;
    int noofeven =0 ;
    int noofodd = 0 ;
    for(int i = 0 ;i<n;i+=1)
    {
        int x;
        cin>>x;
        if(x%2)
        {
            noofodd+=1;
        }
        else{
            noofeven+=1;
        }
    }
    if(p==0)
    {
        ll ans =0  ;
        for(ll j = 0;j<=noofeven;j+=1)
        {
            ll y = C(noofeven,j);
            ans+=y;
            
        }
       // cout<<ans<<" ";
        ll ans2 = 0;
        for(ll j = 0 ;j<=noofodd;j+=2)
        {
            ans2+=(C(noofodd, j));
        }
       // cout<<ans2<<" ";
        ans*=ans2;
        cout<<ans<<endl;
        
    }
    else if(p==1)
    {
        ll ans = 0 ;
        //select odd number of odds;
        for(int i = 1;i<=noofodd;i+=2)
        {
            ans+=C(noofodd,i);
        }
        ans*=expo(2,noofeven);
        cout<<ans<<endl;
    }

    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll a[100005];
ll b[100005];

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 1; i < n; i++)
    {
        b[i] = a[i - 1] * 2 - b[i - 1];
    }
    b[0] += a[n - 1] - b[n - 1] / 2;
    printf("%lld", b[0]);
    for(ll i = 1; i < n; i++)
    {
        b[i] = a[i - 1] * 2 - b[i - 1];
        printf(" %lld", b[i]);
    }
    return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[210000];
int dp[210000];
int inv[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);p[i]--;
		inv[p[i]]=i;
	}
	for(int i=0;i<a;i++){
		dp[i]=1;
		if(p[i]&&inv[p[i]-1]<i){
			dp[i]=dp[inv[p[i]-1]]+1;
		}
	}
	int ret=0;
	for(int i=0;i<a;i++)ret=max(ret,dp[i]);
	printf("%d\n",a-ret);
}

Measured memory_bytes: 2560
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = r * 100 + g * 10 + b;

		if (n % 4 == 0) out.println("YES");
		else out.println("NO");

		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 20820
//include tourist
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

bool is_prime(int n){
    for(int i = 2; i*i <= n ; i++){
        if(n%i == 0)return false;
    }
    return n != 1;
}

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

  for (int i = x; i < 1e9; i++) {
    if (is_prime(i)) {
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    int n = s.length();
    int c = 0;
    for(int i = 0; i < n; ++i)  c += (s[i] == 'g');
    int ans = c - (n + 1) / 2;
    cout << ans << endl;
}

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


int main()
{
   int  n,a,b;
   cin >> n >> a >> b;
   int one = n * a;
   cout << min(one,b) << endl;
}


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

n = int(raw_input())
A = {0}
for c in raw_input().split():
    for i in A.copy():
        A.add(i+int(c))
q = int(raw_input())
M = map(int, raw_input().split())
for m in M:
    if m in A:
        print "yes"
    else:
        print "no"

Measured memory_bytes: 6460
A,B,K= map(int, input().split())

if A == B:
  print(A)
  exit()


ans = [i for i in range(A,min(A+K,B))] + [i for i in range(B,max(B-K,A),-1)] 
[print(num) for num in sorted(list(set(ans)))]

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

int n, m, k;
vector<vector<int>> friends(101010, vector<int>(0)), blocks(101010, vector<int>(0));
vector<int> groups(101010), population(101010);

int dfs(int a, int c){
  int ret = 1;
  groups[a] = c;
  
  for(int x : friends[a]){
    if(groups[x] != 0) continue;
    ret += dfs(x, c);
  }
  return ret;
}

int main(){
  cin >> n >> m >> k;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  rep(i, k){
    int c, d;
    cin >> c >> d;
    blocks[c].push_back(d);
    blocks[d].push_back(c);
  }
  for(int i = 1; i <= n; i++){
    if(groups[i] != 0)continue;
    population[i] = dfs(i, i);
  }
  for(int i = 1; i <= n; i++){
    int res = population[groups[i]] - 1;
    res -= friends[i].size();
    for(int x : blocks[i]){
      if(groups[x] == groups[i])
        res--;
    }
    cout << res << ((i == n)? "\n" : " ");
  }
  return 0;
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll ans=0,n;
    vector<string>v;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(all(s));
        v.push_back(s);
    }
    sort(all(v));
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(i+1<n && v[i]==v[i+1])
            cnt++;
        else{
            ans+=(cnt*(cnt+1))/2;
            cnt=0;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
	double x, y;
	Point(double x = 0.0, double y = 0.0) :
			x(x), y(y) {
	}

	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(double k) {
		return Point(x * k, y * k);
	}
	Point operator /(double k) {
		return Point(x / k, y / k);
	}

	double norm() {
		return x * x + y * y;
	}
	double abs() {
		return sqrt(norm());
	}

	bool operator <(Point p) {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator ==(Point p) {
		return equals(x, p.x) && equals(y, p.y);
	}
};
typedef Point Vector;

class Segment {
public:
	Point p1, p2;
	Segment(Point p1 = Point(), Point p2 = Point()) :
			p1(p1), p2(p2) {
	}
};
typedef Segment Line;

double dot(Vector v1, Vector v2) {
	return v1.x * v2.x + v1.y * v2.y;
}

double cross(Vector v1, Vector v2) {
	return v1.x * v2.y - v1.y * v2.x;
}

bool isorthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isparallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		Segment s1, s2;
		cin >> s1.p1.x >> s1.p1.y;
		cin >> s1.p2.x >> s1.p2.y;
		cin >> s2.p1.x >> s2.p1.y;
		cin >> s2.p2.x >> s2.p2.y;
		if (isparallel(s1, s2))
			cout << 2 << endl;
		else if (isorthogonal(s1, s2))
			cout << 1 << endl;
		else
			cout << 0 << endl;
	}
	return 0;
}



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

int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  int e, f; cin >> e >> f;
  double conc = 0;
  pair<int,int> ans; 
  ans.first = 100 * a;
  ans.second = 0;
  for(int i = 0; i * 100 * a <= f ;i++){
    for(int j = 0; i * 100 * a + j * 100 * b <= f; j++){
      int water = 100 * a * i + 100 * b * j;
      if(water == 0) continue;
      for(int k = 0; water + k * c <= f; k++){
        for(int l = 0; water + k * c + l * d <= f; ++l){
           int salt = k * c + l * d;
           if(salt > e * water/100) break;
           if(conc < (double)salt/(double)water){
             conc = (double)salt/(double)water;
            //  cout << "i, j, k, l: " << i <<" "<< j<<" " << k <<" "<< l << " "<<conc << endl;
             ans.first = water + salt;
             ans.second = salt;
           }
        }
      }
    }
  }
  cout << ans.first << " " << ans.second << endl;
  return 0; 
}


Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var A = new long[N];
            for (var i = 0; i < N; ++i)
                A[i] = Sarray()[0];
            Array.Sort(A);
            var An = new long[2 * N + 1];
            var left = N;
            var right = N;
            An[right] = A[N - 1];
            var b = 0; var e = N - 2;
            for (var i = 0; i < N - 1; ++i)
            {
                var b1 = Abs(A[b] - An[left]);
                var b2 = Abs(A[b] - An[right]);
                var e1 = Abs(A[e] - An[left]);
                var e2 = Abs(A[e] - An[right]);
                if (Max(b1, b2) < Max(e1, e2))
                {
                    if (e1 < e2)
                        An[++right] = A[e--];
                    else
                        An[--left] = A[e--];
                }
                else
                {
                    if (b1 < b2)
                        An[++right] = A[b++];
                    else
                        An[--left] = A[b++];
                }
            }
            var ans = 0L;
            for (var i = left; i < right; ++i)
                ans += Abs(An[i + 1] - An[i]);
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 19016
// A C++ program to find bridges in a given undirected graph
#include<iostream>
#include <list>
#define NIL -1
using namespace std;

// A class that represents an undirected graph
class Graph
{
	int V; // No. of vertices
	list<int> *adj; // A dynamic array of adjacency lists
	void bridgeUtil(int v, bool visited[], int disc[], int low[],
					int parent[]);
public:
	Graph(int V); // Constructor
	void addEdge(int v, int w); // to add an edge to graph
	void bridge(); // prints all bridges
};

Graph::Graph(int V)
{
	this->V = V;
	adj = new list<int>[V];
}

void Graph::addEdge(int v, int w)
{
	adj[v].push_back(w);
	adj[w].push_back(v); // Note: the graph is undirected
}

// A recursive function that finds and prints bridges using
// DFS traversal
// u --> The vertex to be visited next
// visited[] --> keeps tract of visited vertices
// disc[] --> Stores discovery times of visited vertices
// parent[] --> Stores parent vertices in DFS tree
int ans=0;
void Graph::bridgeUtil(int u, bool visited[], int disc[],
								int low[], int parent[])
{
	// A static variable is used for simplicity, we can
	// avoid use of static variable by passing a pointer.
	static int time = 0;

	// Mark the current node as visited
	visited[u] = true;

	// Initialize discovery time and low value
	disc[u] = low[u] = ++time;

	// Go through all vertices aadjacent to this
	list<int>::iterator i;
	for (i = adj[u].begin(); i != adj[u].end(); ++i)
	{
		int v = *i; // v is current adjacent of u

		// If v is not visited yet, then recur for it
		if (!visited[v])
		{
			parent[v] = u;
			bridgeUtil(v, visited, disc, low, parent);

			// Check if the subtree rooted with v has a
			// connection to one of the ancestors of u
			low[u] = min(low[u], low[v]);

			// If the lowest vertex reachable from subtree
			// under v is below u in DFS tree, then u-v
			// is a bridge
			if (low[v] > disc[u])
			ans++;
		}

		// Update low value of u for parent function calls.
		else if (v != parent[u])
			low[u] = min(low[u], disc[v]);
	}
}

// DFS based function to find all bridges. It uses recursive
// function bridgeUtil()
void Graph::bridge()
{
	// Mark all the vertices as not visited
	bool *visited = new bool[V];
	int *disc = new int[V];
	int *low = new int[V];
	int *parent = new int[V];

	// Initialize parent and visited arrays
	for (int i = 0; i < V; i++)
	{
		parent[i] = NIL;
		visited[i] = false;
	}

	// Call the recursive helper function to find Bridges
	// in DFS tree rooted with vertex 'i'
	for (int i = 0; i < V; i++)
		if (visited[i] == false)
			bridgeUtil(i, visited, disc, low, parent);
}

// Driver program to test above function
int main()
{
    int n,m;
    cin>>n>>m;
    Graph g1(n+9);
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g1.addEdge(a,b);
        g1.addEdge(b,a);
    }
	 g1.bridge();
     cout<<ans<<endl;
}






Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	int l = s.size();
	map<char, int> mp;
	rep(i, l) {
		mp[s[i]]++;
	}
	for (auto x : mp) {
		if (x.second % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	/*for (auto x : mp) {
		std::cout << x.first << " " << x.second << "\n";
	}*/
	return 0;
}

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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout << a[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+20 , INF = 0x3f3f3f3f;
int n,a[N],odd[N<<2],even[N<<2]; // even偶数 , odd奇数
inline void update(int &x,int y) { if ( a[x] > a[y] ) x = y; }
inline void build(int p,int l,int r)
{
    if ( l == r )
        return ( ( l & 1 ) ? odd[p] = l : even[p] = l ) , void();
    int mid = l + r >> 1;
    build( p<<1 , l , mid ) , build( p<<1|1 , mid+1 , r );
    update( odd[p] , odd[p<<1] ) , update( odd[p] , odd[p<<1|1] );
    update( even[p] , even[p<<1] ) , update( even[p] , even[p<<1|1] );
}
inline int query(int p,int l,int r,int ql,int qr,int op)
{
    if ( ql <= l && qr >= r ) return op ? even[p] : odd[p];
    int mid = l + r >> 1 , res = 0;
    if ( ql <= mid ) update( res , query(p<<1,l,mid,ql,qr,op) );
    if ( qr > mid ) update( res , query(p<<1|1,mid+1,r,ql,qr,op) );
    return res;
}
struct sec
{
    int l,r,ansl,ansr,op;
    sec (int _l,int _r,int _op)
    {
        l = _l , r = _r , op = _op;
        ansl = query(1,1,n,l,r,op);
        ansr = query(1,1,n,ansl+1,r,op^1);
    }
    friend bool operator < (sec x,sec y)
    {
        if ( a[x.ansl] == a[y.ansl] )
            return a[x.ansr] < a[y.ansr];
        return a[x.ansl] < a[y.ansl];
    }
};
set <sec> S;
inline void solve(void)
{
    S.insert( sec(1,n,0) );
    while ( S.size() )
    {
        sec now = *S.begin(); S.erase(now);
        printf("%d %d ",a[now.ansl],a[now.ansr]);
        if ( now.l < now.ansl-1 ) S.insert(sec(now.l,now.ansl-1,now.op));
        if ( now.ansl+1 < now.ansr-1 ) S.insert(sec(now.ansl+1,now.ansr-1,now.op^1));
        if ( now.ansr+1 < now.r ) S.insert(sec(now.ansr+1,now.r,now.op));
    }
}
inline void input(void)
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
}
int main(void)
{
    input();
    a[0] = INF;
    build( 1 , 1 , n );
    solve();
    return puts("") , 0;
}


Measured memory_bytes: 10880
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        int sum = 0;
        for(int i = 0; i < n; i++){
            int l = sc.nextInt();
            sum += l;
            if(l > max){
                max = l;
            }
        }
        if(max < sum - max){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

int main() {

	string s;
	cin >> s;

	int n = s.length();

	int num_s = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S') {
			num_s++;
		}
		else if (s[i] == 'T' && num_s > 0) {
			num_s--;
			n -= 2;
		}
	}

	cout << n << endl;

	return 0;

}

Measured memory_bytes: 640
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s,t; std::cin >> s >> t;
	int a,b;
	std::cin >> a >> b;
	std::string x;
	std::cin >> x;
	if(x==s) a--;
	if(x==t) b--;
	std::cout << a << ' ' << b << ENDL;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(void){
    int S, h, m, s;
    cin >> S;
    h =  S/3600;
    m = (S-h*3600)/60;
    s = S-(h*3600+m*60);
    cout << h;
    cout << ":";
    cout << m;
    cout << ":";
    cout << s;
    cout << endl;
     
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  ll ans = accumulate(v.begin(), v.end(), 0ll);
  if (ans % 10 == 0) {
    for (int i = 0; i < n; i++) {
      if (v[i] % 10 != 0) {
        cout << ans - v[i] << endl;
        return 0;
      }
    }
  } else {
    cout << ans << endl;
    return 0;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = 0;
		int sum = 0;
		int a = Integer.parseInt(sc.nextLine());
		while(sc.hasNext()) {
			int i = Integer.parseInt(sc.next());
			max = Math.max(max, i);
			sum += i;
		}
		int sum2 = sum - max;
		if(max < sum2) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
#include<stdio.h>
int main(){
    char s[20],t[20];
    scanf("%s",s);
    scanf("%s",t);
    int i=0,temp;
    while(s[i]!='\0'){
        if(s[i]==t[i]) i++;
        else break;
    }
    if(t[i+1]=='\0') printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
using namespace std;
 
int main() {
    int N,cnt=0;
    cin >> N;
 
    for (int i=1; i<=N;  i++) {
        if (i % 2 == 1) {
            int c=0;
            for (int j=1; j<=i; j++) {
                if (i % j == 0) {
                    c++;
                }
            }
            if (c == 8) {
                cnt++;
            }
        }
    }
 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256