akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int n; cin >> n;
	vector<double> x(n), y(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < n; i++) cin >> y[i];
	for (int p = 1; p <= 3; p++) {
		double sum = 0;
		for (int i = 0; i < n; i++) sum += pow(abs(x[i] - y[i]), p);
		printf("%.10f\n", pow(sum, 1.0 / p));
	}
	double maxi = 0;
	for (int i = 0; i < n; i++) maxi = max(maxi, abs(x[i] - y[i]));
	printf("%.10f\n", maxi);
}

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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N, W;
  cin >> N >> W;
  vector<int> weight(N);
  vector<int> value(N);
  for(int i = 0; i < N; ++i)
  {
    cin >> weight[i] >> value[i];
  }
  
  vector<int64_t> dp(W + 1, 0);
  
  for(int i = N - 1; i >= 0; --i)
  {
    for(int j = W; j >= weight[i]; --j)
    {
      dp[j] = max(dp[j], value[i] + dp[j - weight[i]]);
    }
  }
  
  cout << dp[W] << "\n";
  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

vector<string> field;

int main(){
  //入力
  int H,W,K; cin>>H>>W>>K;
  field.resize(H);
  for (int h = 0; h < H; ++h) cin >> field[h];

  vector<int> cnt(H);
  int ans[H][W];
  rep(i,H){
    rep(j,W){
      ans[i][j] = 0;
    }
  }

  rep(i,H){
    rep(j,W){
      if(field[i][j] == '#') cnt[i]++;
    }
  }

  //rep(i,H) cout<<cnt[i]<<endl;

  //countが0ではなければそれぞれのれつで分割
  ll tmp = 1;

  rep(i,H){
    bool ok = false;
    if(cnt[i] != 0){
      rep(j,W){
        if(ok and field[i][j] == '#') tmp++;
        ans[i][j] = tmp;
        if(ok == false and field[i][j] == '#') ok = true;
      }
      tmp++;
    }
  }

  //0を埋めていく作業
  rep(i,W){
    int tmp2 = 0;
    rep(j,H){
      if(ans[j][i] == 0) ans[j][i] = tmp2;
      if(ans[j][i] != 0) tmp2 = ans[j][i];
    }
  }

  rep(i,W){
    int tmp3 = ans[H-1][i];
    for(int j = H-1;j>=0;j--){
      if(ans[j][i] == 0) ans[j][i] = tmp3;
      if(ans[j][i] != 0) tmp3 = ans[j][i];
    }
  }


  //出力
  rep(i,H){
    rep(j,W){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }

}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int checkCF(string str);


int main(){
	string str;

	cin>>str;

	if(checkCF(str))cout << "Yes" <<endl;
	else cout << "No" <<endl;

	return 0;
}

int checkCF(string str){
	for(int i=0;i<str.size();i++){
		if(str[i]=='C')
			for(int j=i;j<str.size();j++){
				if(str[j]=='F')return 1;
			}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		HashMap<Long,Long> B=new HashMap<Long, Long>();
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long A[]=new long[N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextLong();
			if(i-A[i]>=0) {
				long count = B.containsKey(i-A[i]) ? B.get(i-A[i]) : 0;
				B.put(i-A[i], count + 1);
			}
		}
		long ans=0;
		for(int i=0;i<N;i++) {
			if(B.containsKey(i+A[i]))
			ans+=B.get(i+A[i]);
			if(i-A[i]>=0) {
				long count = B.containsKey(i-A[i]) ? B.get(i-A[i]) : 0;
				B.put(i-A[i], count - 1);
			}
		}
		System.out.println(ans);
}
}


Measured memory_bytes: 69548
#include <map>
#include <list>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,c,x,y;
int main()
{
	fast; 
	cin>>a>>b>>c>>x>>y;
	if (a+b<=2*c)
	   cout<<a*x+b*y;
	else if (x>y)
	   cout<<min(2*y*c+a*(x-y),2*c*max(x,y));
	else
	   cout<<min(2*x*c+b*(y-x),2*c*max(x,y));
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
void solveforthiscase(const int & test)
{
cin>>n>>m;
cin>>k;
vector<ll> a=read(n);
vll b=read(m);
vll psa(n),psb(m);
psa[0]=a[0];
psb[0]=b[0];
for(int i=1;i<n;i++)
psa[i]=psa[i-1]+a[i];
for(int i=1;i<m;i++)
psb[i]=psb[i-1]+b[i];
ll mx=upper_bound(all(psb),k)-psb.begin();
mx=max(mx,upper_bound(all(psa),k)-psa.begin());
for(int i=0;i<n;i++)
{
    if(psa[i]>k)
    break;
    ll rem=k-psa[i];
    int cnt=upper_bound(all(psb),rem)-psb.begin();
    mx=max(i+1+cnt,mx);
}
cout<<mx;










return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE 
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout); 
    // freopen("error.txt", "w", stderr); 
    // #endif 
    clock_t start, end;
    start = clock(); 
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    solveforthiscase(i);
    end = clock(); 
    long double t_t = (long double)(end - start) /(long double)(CLOCKS_PER_SEC); 
    cerr << (long double)t_t*1000<< " ms ";
}


Measured memory_bytes: 9576
N, A, B, C = map(int,input().split())
L = [int(input()) for _ in range(N)]

def dfs(x, a, b, c):
  if(x == N):
    if(min(a, b, c) > 0):
      return abs(a-A)+abs(b-B)+abs(c-C)-30
    else:
      return 1e9+7
  ret0 = dfs(x+1, a, b, c)
  ret1 = dfs(x+1, a+L[x], b, c) + 10
  ret2 = dfs(x+1, a, b+L[x], c) + 10
  ret3 = dfs(x+1, a, b, c+L[x]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int index=distance(a.begin(),upper_bound(a.begin(),a.end(),-1));
  if(index==0){
    index=1;
  }else if(index==n){
    index=n-1;
  }
  int temp=a[0];
  int sum1=a[0],sum2=a[n-1];
  for(int i=index;i<n-1;i++){
    sum1-=a[i];
  }
  a[0]=sum1;
  for(int i=0;i<index;i++){
    sum2-=a[i];
  }
  cout<<sum2<<endl;
  a[0]=temp;
  sum1=a[0],sum2=a[n-1];
  for(int i=index;i<n-1;i++){
    cout<<sum1<<' '<<a[i]<<"\n";
    sum1-=a[i];
  }
  a[0]=sum1;
  for(int i=0;i<index;i++){
    cout<<sum2<<' '<<a[i]<<"\n";
    sum2-=a[i];
  }
  return 0;
}

Measured memory_bytes: 3788
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    n = int(input())
    s = list(input())
    ans = float("inf")
    a = [0]+[ 0 if tmp != 'W' else 1 for tmp in s ]
    b = list(reversed([ 0 if tmp != 'E' else 1 for tmp in s ]+[0]))
    for tmp in range(n-1):
        a[tmp+1] += a[tmp]
        b[tmp+1] += b[tmp]
    else:
        a.pop()
        b.pop()
        b = list(reversed(b))
    for tmp in range(n):
        ans = min(ans, a[tmp]+b[tmp])
    else:
        print(ans)

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

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

ll f(ll b, ll n){
    if(n < b){
        return n;
    }
    return (f(b, n / b) + (n % b));
}

int main() {
    //cout.precision(10);
    ll n, s;
    cin >> n >> s;
    if(n < s){
        cout << -1 << endl;
        return 0;
    }
    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }
    for(ll i = 2; i <= 1000000; i++){
        if(f(i, n) == s){
            cout << i << endl;
            return 0;
        }
    }
    for(ll i = 1000000; i >= 1; i--){
        if(i * i >= n){
            continue;
        }
        ll two = i;
        ll one = s - i;
        if(one < 0){
            continue;
        }
        if(((n - one) % two) != 0){
            continue;
        }
        ll ans = (n - one) / two;
        if(two >= ans){
            continue;
        }
        if(one>= ans){
            continue;
        }
        cout << ans << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
ll n, k;

int main()
{
	scanf("%lld%lld", &n, &k);
	ll ans = 0;
	for (ll i = k; i <= n+1; i++) {
		ans = (ans + ((i*(n-i+1)) % mod + 1) % mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3808
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=ja

# union-find

n, q = map(int, input().split())

# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1] * n


for _ in range(q):
    com, ai, bi = map(int, input().split())
    # ai, bi = ai - 1, bi - 1

    # com = 0 (unite) / 1 (same)
    if com == 0:
        unite(ai, bi)
    else:
        print(1 if same(ai, bi) else 0)


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

int main(){
  int n, count=0; cin >> n;
  for(int i=0;i<=n;i++){
    if(i>0 && to_string(i).size()%2 != 0) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3708
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>
#include <string>

#define REP(i,n) for(int i=0;i<(n);++i)
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef pair<double,int> P;
typedef long long ll;
struct Line{
  double a,b,c;
  int order;
  int operator<(const Line& l) const {
    return 1;
  }
};
typedef pair<double,Line> PL;
struct FenwickTree {
  static const int MAX_N = 50000;
  ll storage[MAX_N+1];
  int N;
  void init(int n) {
    N=n;
    for(int i=0;i<MAX_N;++i) {
      storage[i]=0;
    }
  }
  ll sum(int i) { // 0<i<=N
    if (i==0) return 0;
    int ret = 0;
    while(i>0) {
      ret+=storage[i];
      i -= i&-i;
    }
    return ret;
  }
  void add(int i, ll x) {// 0<=i<N
    ++i;
    while(i<=N) {
      storage[i] += x;
      i += i&-i;
    }
  }
  ll rangeSum(int l, int r) {
    return sum(r)-sum(l);
  }
};

ll N;
FenwickTree ft;
PL pls[4*10000+10];
P angles[4*10000+10];
bool isOK(double d) {
  ft.init(N+10);
  for(int i=0;i<N;++i) {
    double val= (pls[i].second.c -pls[i].second.a*d ) /pls[i].second.b;
    angles[i]=P(val,i);
  }
  sort(angles, angles + N);
  for(int i=0;i<N;++i) {
    pls[angles[i].second].second.order=i;
  }
  ll numLine=0;
  for(int i=0;i<N;++i) {
    numLine += ft.rangeSum(0,pls[i].second.order+1);
    ft.add(pls[i].second.order,1);
  }
  return numLine >= (N*(N-1)/2+2)/2;
}
double INF=1.0*1000*1000*1000;
double EPS=0.000000001;
double solve() {
  for(int i=0;i<N;++i) {
    pls[i].first = pls[i].second.a /pls[i].second.b;
  }
  sort(pls, pls+N);
  double l=-INF,r=INF;
  for(int i=0;i<=70;++i) {
    double m=(r+l)/2;
    if (isOK(m)) {
      l=m;
    } else {
      r=m;
    }
  }
  return l;
}
int main() {
  cin >> N;
  REP(i, N) {
    int A,B,C;
    scanf("%d%d%d", &A, &B, &C);
    pls[i]=PL(0.0,{1.0*A,1.0*B,1.0*C,0});
  }

  double x=solve();
  for(int i=0;i<N;++i) {
    double temp=pls[i].second.a;
    pls[i].second.a=pls[i].second.b;
    pls[i].second.b=temp;
  }
  double y=solve();
  printf("%.15lf %.15lf\n", x, y);
  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vii dp;
vi w;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);


    vii dp_init(310, vi(310));
    vi w_init(310);
    int n, p;
    while(cin >> n) {
        if(n==0) break;
        dp = dp_init;
        w = w_init;
        rep1(i,n) cin >> w[i];

        for(int l = 2; l <= n; ++l) {
            for(int i = 0; i+l <= n; ++i) {
                int j = i + l;
                if(dp[i+1][j-1] == (j-1)-(i+1)) {
                    if(abs(w[i+1]-w[j]) <= 1) chmax(dp[i][j], dp[i+1][j-1] + 2);
                }
                for(int k = i+1; k < j; ++k) {
                    chmax(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
        cout << dp[0][n] << '\n';
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using lint = long long;
using ld = long double;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(lint i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	lint n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}
/* --------------------------------------- */


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  vector<P> vec;
  for(int i = 1; i < n-1; ++i) {
    if(a[i] >= 0) {
      vec.emplace_back(a[0], a[i]);
      a[0] -= a[i];
    }
    else {
      vec.emplace_back(a[n-1], a[i]);
      a[n-1] -= a[i];
    }
  }
  vec.emplace_back(a[n-1], a[0]);
  ll ans = a[n-1]-a[0];
  cout << ans << endl;
  for(auto x : vec) cout << x.first << " " << x.second << endl;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n;
	cin >> n;
	int arr[MAX];
	REP(i, n){
		cin >> arr[i];
	}
	int  mx = 0, curr = 0;
	REP(i, n - 1){
		if (arr[i + 1] <= arr[i]) ++curr;
		else{
			if (mx < curr) {
				mx = curr;
			}
			curr = 0;
		}
	}
	mx = max(curr, mx);
	cout << mx << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

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

int main() {
	int x,y,ans=0;
	cin >> x >> y;
	ans+=max(0,4-x)*100000;
	ans+=max(0,4-y)*100000;
	if(x==1 && y==1){
		ans+=400000;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
sum_min = 10 ** 6
for a in 1..(n / 2) do
  b = n - a
  a_sum = a.to_s.split("").map(&:to_i).inject(:+)
  b_sum = b.to_s.split("").map(&:to_i).inject(:+)
  sum = a_sum + b_sum
  sum_min = sum if sum < sum_min
end
puts sum_min


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

int main(void){
    // Here your code !
    int n,ans=0;
    scanf("%d",&n);
    
    int a[n];
    for(int i=0;i<n; i++){
        scanf("%d",&a[i]);
        a[i]--;
    }
    for(int i=0;i<n;i++){
        if(a[i]>i){
            if(a[a[i]]==i){
                ans++;
            }
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<iostream>
    using namespace std;
    int main()
    {
    	ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        int n;
        cin>>n;
        while(n>0)
        {
        	if(n%10==7)
        	{
        		cout<<"Yes";
        		break;
        	}
        	n=n/10;
        } 
        if(n==0)
        	cout<<"No";
    }

Measured memory_bytes: 3664
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<queue>
#include<map>
using namespace std;
int v[55];
int main()
{
	int n,a,b,c,k;
	int ans=-10000000;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&v[i]);
	for(a=0;a<=k;a++)
	{
		for(b=0;b<=k;b++)
		{
			for(c=0;c<=k;c++)
			{
				if((a+b+c)<=k&&(a+b)>=c&&(a+b)<=n)
				{
					priority_queue<int> q;
					for(int i=0;i<a;i++)
						q.push(v[i]);
					for(int i=0;i<b;i++)
						q.push(v[n-i-1]);
					int sum=0;
					for(int i=0;i<a+b-c;i++)
					{
						sum+=q.top();
						q.pop();
					}
					ans=max(ans,sum);
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int n;cin>>n;
    int k;cin>>k;
    int sum = 1;
    rep(i,n){
        if(sum*2>sum+k){
            sum=sum+k;
        }
        else sum=sum*2;
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 3620
/*
AizuOnline A0022
Maximum Sum Sequence
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int len;
char train[100];
char buf[600][73];
int bptr,blen;

void init()
{
  // strcpy(train,"abcd");
  scanf("%s",train);
}

void print()
{
  int i;
  for(i=0;i<blen;i++)
    printf("%s\n",&(buf[i][0]));
}

int comp (char * s1,char * s2)
{
  return(strcmp(s1,s2));
}
void sort_buf()
{
  qsort(buf,blen,73,(__compar_fn_t)comp);
}

void strncpy_rev(char * d,char * s,size_t n)
{
  int i;

  for(i=0;i<n;i++)
    d[n-1-i]=s[i];
}

int uniq()
{  int i,cnt;
  cnt=1;
  for(i=0;i<blen-1;i++)
    if(0!=strncmp(&(buf[i][0]),&(buf[i+1][0]),len))
      cnt++;
  return(cnt);
}

main()
{ 
  int i,ret,t;
  int N;

  scanf("%d",&N);
  for(t=0;t<N;t++)
  {
 init ();

  bptr=0;

  len = strlen(train);
  //printf("len=%d\n",len);
  for(i=1;i<len;i++)
    {
      strncpy(&(buf[bptr][0]),train,i);
      strncpy(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy(&(buf[bptr][0]),train+i,len-i);
      strncpy(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;

      strncpy_rev(&(buf[bptr][0]),train,i);
      strncpy(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy_rev(&(buf[bptr][0]),train+i,len-i);
      strncpy(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;

      strncpy(&(buf[bptr][0]),train,i);
      strncpy_rev(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy(&(buf[bptr][0]),train+i,len-i);
      strncpy_rev(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;

      strncpy_rev(&(buf[bptr][0]),train,i);
      strncpy_rev(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy_rev(&(buf[bptr][0]),train+i,len-i);
      strncpy_rev(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;
    }
  blen=bptr; // output buffer size

  sort_buf();
  ret=uniq();
  //print();
  printf("%d\n",ret);
}


  return(0);
}

Measured memory_bytes: 728
#include<iostream>
#include<vector>
#include<string>

int main(){
	while(1){
		int a=0;
		std::cin >> a;
		if(a==0)break;
		std::string str;
		for (int i=0 ; i<2*a ; i++){
			str.push_back (' ');
		}

		char c;
		for (int i=0 ; i<2*a ; i++){
			std::cin>> c;
			str[i]=c;
			c=' ';
		}
		int b=0;
		std::cin >>b;
		std::string str1;
		for(int i=0 ; i<b ; i++){
			str1.push_back (' ');
		}
		char d;
		for (int i=0 ; i<b ; i++){
			std::cin>> d;
			str1[i]=d;
			d=' ';
		}
		int x=0;
		for(int j=0 ; j<b; j++){
			for(int i=0 ; i<2*a ; i=i+2){
				if(str1[j]==str[i]){
					std::cout<<str[i+1];
					x++;
				}
			}
			if(x==0)std::cout<<str1[j];
			x=0;
		}
		std::cout<<std::endl;
	}
return 0;
}

Measured memory_bytes: 1328
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
vector<int> G[150000];
double dp[150000];
double dp2[150000];
void dfs1(int v, int par) {
	int cnt = 0;
	rep(i, G[v].size()) {
		int to = G[v][i];
		if (to == par) continue;
		dfs1(to, v);
		dp[v] += (dp[to] + 1);
		cnt++;
	}
	if (cnt > 0) dp[v] /= cnt;
}
void dfs2(int v, double d_par, int par) {
	rep(i, G[v].size()) {
		int to = G[v][i];
		if (to == par) dp2[v] += (d_par + 1);
		else dp2[v] += (dp[to] + 1);
	}
	rep(i, G[v].size()) {
		int to = G[v][i];
		if (to == par) continue;
		double D = dp2[v] - (dp[to] + 1);
		if (G[v].size() > 1) D /= (G[v].size() - 1);
		dfs2(to, D, v);
	}
	dp2[v] /= G[v].size();
}
int main() {
	int N;
	cin >> N;
	rep(i, N - 1) {
		int u, v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs1(0, -1);
	dfs2(0, 0, -1);
	rep(i, N) {
		printf("%.15lf\n", dp2[i]);
	}
}

Measured memory_bytes: 19328
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int N, M, X, Y;
    vector<int> x, y;
    cin >> N >> M >> X >> Y;
    int hoge;
    for (int i = 0; i < N; i++)
    {
        cin >> hoge;
        x.push_back(hoge);
    }
    for (int i = 0; i < M; i++)
    {
        cin >> hoge;
        y.push_back(hoge);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int z = -1;
    for (int i = x[N - 1] + 1; i <= y[0]; i++)
        if (X < i && i <= Y)
            z = i;

    if (z == -1)
        cout << "War" << endl;
    else
        cout << "No War" << endl;

    return 0;
}

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

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

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

ll GCD(ll a,ll b) {
  if(a > b) swap(a,b);
  if(a == 0) return b;
  while(b % a != 0) {
    b = b % a;
    swap(a,b);
  }
  return a;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,n) cin >> a[i+1];
  ll ans = 0;
  vector<ll> l(n+2);
  vector<ll> r(n+2);
  l[0] = 0; r[n+1] = 0;
  rep(i,n) {
    l[i+1] = GCD(l[i],a[i+1]);
    r[n-i] = GCD(r[n-i+1],a[n-i]);
  }
  for(int i = 1; i <= n; i++) {
    ans = max(ans,GCD(l[i-1],r[i+1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int min, mid ,max,esc;
    scanf("%d %d %d",&min,&mid,&max);
    if(mid < min){
        esc = mid;
        mid = min;
        min = esc;
    }
    if(max < mid){
        esc = max;
        max = mid;
        mid = esc;
    }
    if(mid < min){
        esc = mid;
        mid = min;
        min = esc;
    }
    printf("%d %d %d\n",min,mid,max);
    return 0;
}

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

#define int long long

typedef complex<int> Point;

bool Comp(const Point &p, const Point &q)
{
    if (p.real() != q.real()) return p.real() < q.real();
    return p.imag() < q.imag();
}

int Cross(const Point &p, const Point &q)
{
    return p.real()*q.imag() - p.imag()*q.real();
}

bool IsNG(const Point &p1, const Point &p2, const Point &p3)
{
    return Cross(p2 - p3, p1 - p2) <= 0;
}

double GetDistance(const Point &p, const Point &q)
{
    int dx = p.real() - q.real();
    int dy = p.imag() - q.imag();
    return sqrt(dx*dx + dy*dy);
}

vector<Point> SortReew(vector<Point> ps)
{
    sort(ps.begin(), ps.end(), Comp);
    vector<Point> u;
    for (int i = 0; i < ps.size(); i++)
    {
        while (u.size() > 1 && IsNG(ps[i], u[u.size() - 1], u[u.size() - 2]))
            u.pop_back();
        u.push_back(ps[i]);
    }
    vector<Point> d;
    for (int i = ps.size() - 1; i >= 0; i--)
    {
        while (d.size() > 1 && IsNG(ps[i], d[d.size() - 1], d[d.size() - 2]))
            d.pop_back();
        d.push_back(ps[i]);
    }
    for (int i = 1; i < d.size() - 1; i++)
    {
        u.push_back(d[i]);
    }
    return u;
}

struct UF
{
    vector<int> par;
    UF(int n)
    {
        par.resize(n);
        for (int i = 0; i < n; i++) par[i] = i;
    }
    int Find(int x)
    {
        if (x == par[x]) return x;
        return par[x] = Find(par[x]);
    }
    bool Unite(int a, int b)
    {
        if (Find(a) == Find(b)) return false;
        par[Find(b)] = Find(a);
        return true;
    }
};

int V, R;
map< pair<int, int>, int> m;

struct Edge
{
    int a, b;
    double cost;
    Edge() {}
    Edge(int a, int b, double cost) : a(a), b(b), cost(cost) {}
    bool operator < (const Edge &e) const
    {
        return cost < e.cost;
    }
};

signed main()
{
    cin >> V >> R;
    vector<Point> v(V);
    for (int i = 0; i < V; i++)
    {
        double x,y;cin>>x>>y;
        v[i]=Point(x,y);
        m[make_pair(v[i].real(), v[i].imag())] = i;
    }
    double ans = 0;
    vector<Point> ret = SortReew(v);
    UF uf(V);
    for (int i = 0; i < ret.size(); i++)
    {
        Point p = ret[i];
        Point q = ret[(i+1)%ret.size()];
        int a = m[make_pair(p.real(), p.imag())];
        int b = m[make_pair(q.real(), q.imag())];
        uf.Unite(a,b);
        ans += GetDistance(v[a], v[b]);
        //cout<<"\t"<<a<<" "<<b<<endl;
    }
    //printf("%.20f\n",ans);
    /*for (int i = 0; i < ret.size(); i++)
    {
        printf("%lld %lld\n", ret[i].real(), ret[i].imag());
    }*/
    vector<Edge> es;
    for (int i = 0; i < R; i++)
    {
        int a, b;
        cin >> a >> b; a--; b--;
        es.push_back( Edge(a, b, GetDistance(v[a], v[b]) ));
    }
    sort(es.begin(), es.end());
    for (int i = 0; i < es.size(); i++)
    {
        if (uf.Unite(es[i].a, es[i].b)) ans += es[i].cost;
    }
    printf("%.20f\n", ans);
    return 0;
}

Measured memory_bytes: 3320
N = int(input())

A_list = list(map(int, input().split()))

A_sorted = sorted(A_list)

pos_count = len([a for a in A_sorted if a >= 0])
neg_count = len([a for a in A_sorted if a < 0])

if pos_count == 0:
    pos_count = 1
    neg_count = N - 1
if neg_count == 0:
    pos_count = N - 1
    neg_count = 1

output_list = [0] * (N - 1)
count = 0
for q in range(neg_count, N - 1):
    output_list[count] = [A_sorted[0], A_sorted[q]]
    count += 1
    A_sorted[0] -= A_sorted[q]


for i in range(neg_count):
    output_list[count] = [A_sorted[N - 1], A_sorted[i]]
    count += 1
    A_sorted[N - 1] -= A_sorted[i]

print(A_sorted[N - 1])
for item in output_list:
    print(item[0], item[1])

Measured memory_bytes: 23012
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define MAX_N 10000000
#define ll int64_t
#define all(v) (v).begin(),(v).end()
using namespace std;

int main() {
    //入力
    int n, m; cin>>n>>m;
    ll count=0;
    using pii=pair<ll,int>;
    vector<pii> a(n);
    rep(i,n) cin>>a[i].first>>a[i].second;
    
    //順序を昇冪にする
    sort(all(a));

    rep(i,n) {
      if(a[i].second>m) {
        count+=(a[i].first*m);
            cout<<count<<endl;
            return 0;
        }
        count+=(a[i].first*a[i].second);
        m-=a[i].second;
    }
    cout<<count<<endl;
    return 0;
} 

Measured memory_bytes: 1792
from itertools import product
A, B, C = map(int, input().split())
K = int(input())
ans = 'No'
for k in range(0, K+1):
    for x in product([1,2,3], repeat=k):
        a, b, c = A, B, C
        for i in range(k):
            if x[i] == 1:
                a = 2*a
            elif x[i] == 2:
                b = 2*b
            else:
                c = 2*c
        if b > a and c > b:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 9200
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

n, k = gets_i_list
hlist = []
n.times do
  hlist.push gets_i
end

hlist.sort!

min = Float::INFINITY

0.upto(n - k) do |i|
  min = [min, hlist[i+k-1] - hlist[i]].min
end

puts min

Measured memory_bytes: 16544
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();

    let n = s.len();
    let mut xv = vec![1i32; n];
    for i in 0..n - 1 {
        if cv[i] == 'R' && cv[i + 1] == 'R' {
            xv[i + 1] += xv[i];
            xv[i] = 0;
        }
    }
    for i in 0..n - 1 {
        let j = n - i - 1;
        if cv[j - 1] == 'L' && cv[j] == 'L' {
            xv[j - 1] += xv[j];
            xv[j] = 0;
        }
    }

    let mut yv = vec![0i32; n];
    let mut i = 0;
    while i < n - 1 {
        if xv[i] != 0 && xv[i + 1] != 0 {
            let y = xv[i] + xv[i + 1];
            if y % 2 == 0 {
                yv[i] = y / 2;
                yv[i + 1] = y / 2;
            } else {
                if max(xv[i], xv[i + 1]) % 2 == 0 {
                    if xv[i] > xv[i + 1] {
                        yv[i] = y / 2;
                        yv[i + 1] = y / 2 + 1;
                    } else {
                        yv[i] = y / 2 + 1;
                        yv[i + 1] = y / 2;
                    }
                } else {
                    if xv[i] > xv[i + 1] {
                        yv[i] = y / 2 + 1;
                        yv[i + 1] = y / 2;
                    } else {
                        yv[i] = y / 2;
                        yv[i + 1] = y / 2 + 1;
                    }
                }
            }
            i += 2;
        } else {
            i += 1;
        }
    }

    for i in 0..n - 1 {
        print!("{} ", yv[i]);
    }
    println!("{}", yv[n - 1]);
}


Measured memory_bytes: 4476
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>

int main()
{
    int n,l;
    cin>>n>>l;

    vector<string> vec(n);
    for(int i=0;i<vec.size();i++){
        cin>>vec[i];
    }

    sort(vec.begin(),vec.end());

    
    for(int i=0;i<vec.size();i++){
        cout<<vec[i];
    }
    
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
\
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;


int main() {
    int n,a,b;
    int ans = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <=n; i ++){
        string tmp = to_string(i);
        int val = 0;
        for(int j = 0; j < tmp.length(); j ++){
            val += (int)(tmp[j] - '0');
        }
        if(val >= a && val <= b) ans += i;
    }
    cout << ans;
}







Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin >> a >> b;
    if(a < b)
    {
        for(int i = 1;i <= b;i ++)
        {
            cout << a;
        }
    }
    else
    {
        for(int i = 1;i <= a;i ++)
        {
            cout << b;
        }
    }
    return 0;
}


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(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int X;
    cin >> X;
    int ans = 0;
    while(ans*(ans+1)/2 < X) ans++;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {

	char w[100] = {}, eng[26] = {};
	int i, j, count = 0, num = 1, engnum[26] = {0};
	bool ans;

	cin >> w;

	while (w[count])
		count++;

	eng[0] = w[0];

	for (i = 0; i < count; i++) {
		for (j = 0; j < num; j++) {
			if (eng[j] == w[i]) {
				engnum[j]++;
				break;
			}
			else {
				if (j == num - 1) {
					eng[num] = w[i];
					engnum[num]++;
					num++;
					break;
				}
				else continue;
			}

		}
	}


	for (i = 0; i < num; i++) {
		if (engnum[i] % 2 != 0) {
			cout << "No" << endl;
			ans = false;
			break;
		}
		else ans = true;
	}

	if (ans)
		cout << "Yes" << endl;

	return 0;

}

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

struct segment_tree{
    static const int SEG=1<<17;
    vector<int>dat;
    segment_tree():dat(SEG*2){}
    void update(int a,int b,int x,int k=0,int l=0,int r=SEG){
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            dat[k]=max(dat[k],x);
            return;
        }
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
    }
    int query(int k){
        k+=SEG-1;
        int ret=dat[k];
        while(k){
            k=(k-1)/2;
            ret=max(ret,dat[k]);
        }
        return ret;
    }
};

const int SIZE=100000;

int N,Q;
vector<int>G[SIZE];

int tt,tin[SIZE],tout[SIZE];
int par[20][SIZE],dep[SIZE];
void dfs(int v,int p,int d){
    par[0][v]=p;
    dep[v]=d;
    tin[v]=tt++;
    for(auto u:G[v])dfs(u,v,d+1);
    tout[v]=tt;
}

int main(){
    while(scanf("%d%d",&N,&Q),N||Q){
        for(int i=0;i<N;i++)G[i].clear();
        for(int i=1;i<N;i++){
            int p;scanf("%d",&p);p--;
            G[p].push_back(i);
        }
        tt=0;
        dfs(0,-1,0);

        for(int i=0;i<19;i++){
            for(int j=0;j<N;j++){
                if(par[i][j]==-1)par[i+1][j]=-1;
                else par[i+1][j]=par[i][par[i][j]];
            }
        }

        segment_tree seg;
        long long ans=0;
        while(Q--){
            char c;
            int v;
            scanf(" %c%d",&c,&v);
            v--;
            if(c=='M'){
                seg.update(tin[v],tout[v],dep[v]);
            }
            else{
                int d=seg.query(tin[v]);
                for(int i=19;i>=0;i--)if((dep[v]-d)>>i&1)v=par[i][v];
                ans+=v+1;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 24188
#include<stdio.h>
int main()
{
	char s[20];
	int i;
	scanf("%s",s);
	for(i = 0;s[i] != '\0';i++)
	{
		if(s[i] >= 'a' && s[i] <= 'z')
			printf("%c",s[i]);
		else
			printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    S = input()

    front = int(S[:2])
    rear = int(S[2:])

    front_mm = 1 <= front <= 12
    rear_mm = 1 <= rear <= 12

    if front_mm and rear_mm:
        print("AMBIGUOUS")
    elif front_mm:
        print("MMYY")
    elif rear_mm:
        print("YYMM")
    else:
        print("NA")


main()


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#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>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}


void solve(){

    ll n;
    cin >> n;
    ll a[n+1];
    for(ll i=1;i<n+1;i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1,greater<ll>());
    ll ans=0;
    map<ll,ll> MAP;
    set<ll,greater<ll>> s;
    for(ll i=1;i<n+1;i++){
        MAP[a[i]]++;
        s.I(a[i]);
    }
    vll b;
    b.pb(a[1]);
    for(ll i=2;i<=n;i++){
        b.pb(a[i]);
        b.pb(a[i]);
    }
    ll ptr=0;
    for(ll i=2;i<=n;i++){
        ans += b[ptr++];
    }
    cout << ans << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 30824
def solve(field, h, w)
  res = Array.new(h).map {Array.new(w, -1)}
  field.each.with_index do |row, i|
    row.each.with_index do |c, j|
      res[i][j] = res[i][j-1] + 1 if res[i][j-1] >= 0 and c == "."
      res[i][j] = 0 if c == "c"
    end
  end
  res.map {|row| row.join(" ")  }.join("\n")
end

h, w = gets.split(" ").map(&:to_i)
field = []
h.times { field << gets.strip.chars }
puts solve(field, h, w)

Measured memory_bytes: 8936
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n,i;
    cin>>n;
    string ans = "";
    while(n>0)
    {
        n--;
        ans += 'a' + (n%26);
        n /= 26;
    }
    reverse(all(ans));
    cout<<ans;


   
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc125/tasks/abc125_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int A, B, T, r;
  cin >> A >> B >> T;

  cout << B * floor((double)T / A) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 min = 1;
  i32 max = n;
  while (m--) {
    i32 l, r;
    scanf ("%" SCNi32 "%" SCNi32, &l, &r);
    min = MAX(min, l);
    max = MIN(max, r);
  }
  if (min <= max) {
    printf ("%" PRIi32 "\n", max - min + 1);
  } else {
    puts ("0");
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  int cnt1 = 0;
  int cnt2 = 0;
  rep(i,s.size()){
    if(s[i] == 'a'){
      if(cnt1<a+b){
        cnt1++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    if(s[i] == 'b'){
      if(cnt1<a+b&&cnt2<b){
        cnt1++;
        cnt2++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    if(s[i] == 'c') cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3712