akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong a, b, c;
  cin >> a >> b >> c;

  if (a < c && c < b || a > c && c > b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main()
{
	int a,b;
	cin>>a>>b;
	if((a+b)%2==1)
		cout<<(a+b)/2+1<<endl;
	else
		cout<<(a+b)/2<<endl;
	return 0;
}

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

using namespace std;


int frog1(const vector<int>& hs) {
    int a=0,b= abs(hs[1]-hs[0]);
    int temp;
    for (size_t i = 2; i < hs.size(); ++i)
    {
        temp=min(b+ abs(hs[i]-hs[i-1]), a + abs(hs[i] - hs[i-2]));
        a=b;
        b=temp;
    }
    return b;
}


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

    int N;
    cin >> N;
    vector<int> hs;
    int h;
    for (size_t i = 0; i < N; ++i)
    {  
        cin>>h;
        hs.push_back(h);
    }

    cout << frog1(hs) << "\n";

}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    int A[110];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int ans = X;
    for (int i = 0; i < N; i++)
    {
        ans += int((D - 1) / A[i]) + 1;
    }

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


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

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

  int x;
  cin >> x;

  if (x < 1200) cout << "ABC\n";
  else cout << "ARC\n";

  return (0);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,t;cin>>n>>t;
    vector<P> v(n);
    rep(i,n){
        ll a,b;cin>>a>>b;
        v[i]=P(a+1,a+b+1);
    }
    //outvp(v);
    vector<pair<double,ll>> s;
    vi u;
    rep(i,n){
        if(v[i].fi-1>0)s.eb(1.0*(v[i].fi-1)/(v[i].se-v[i].fi+1),i);
        else u.pb(v[i].se-v[i].fi+1);
    }
    sort(all(s));reverse(all(s));
    //outvp(s);
    sort(all(u));
    n=s.size();
    if(n==0){
        ll sum=0;
        int j=0;
        while(j<u.size()&&sum+u[j]<=t)j++;
        out(j);
        return 0;
    }
    ll ans=0;
    vvi dp(n,vi(32,t+3));
    dp[0][0]=0;
    dp[0][1]=v[s[0].se].se;
    rep(i,n-1){
        rep(j,31){
            if(dp[i][j]>t)continue;
            ll id=s[i+1].se;
            if(dp[i][j]*v[id].fi+v[id].se<=t)chmin(dp[i+1][j+1],dp[i][j]*v[id].fi+v[id].se);
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    //outvv(dp);
    //outvv(dp);
    rep(i,32)if(dp[n-1][i]<=t){
        int cnt=0;
        while(cnt<u.size()&&u[cnt]+dp[n-1][i]<=t){
            dp[n-1][i]+=u[cnt];
            cnt++;
        }
        //cout<<i<<' '<<ub(rui,t-dp[n-1][i])<<endl;
        chmax(ans,i+cnt);
    }
    out(ans);
}


Measured memory_bytes: 65132
import string
L = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
S = set(input())
for i in L:
  if i not in S:
    print(i)
    break
else:
  print(None)

Measured memory_bytes: 9916
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int a,b;
  cin >> a >> b;
  if(a<=0 && b>=0) cout << "Zero" << endl;
  else if(a>0) cout << "Positive" << endl;
  else{
    if((b-a)%2==0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int a; cin >> a;
  cout << a * (1 + a + a*a);
  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 3636
#include <iostream>

using namespace std;
const int N=2e3+10;
int ans[N];
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    // for(int i=a+1;i<=b-1;i++){
    //     for(int j=i+1;j<=b-1;j++)
    //     {
    //         ans[j-i]++;
    //     }
    // }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(i<=a&&j<=a)ans[j-i]++;
            else if(i>=b&&j>=b)ans[j-i]++;
            else if(i>=a&&j<=b){
                ans[min(j-i,b-a+1-(j-i))]++;
            }else if(i<=a&&j>a){
                int k;
                if(j>=b)k=j-b+1;
                else{
                    k=min(j-a,b-j+1);
                }
                ans[(a-i)+k]++;
            }else{
                int k;
                if(i<=a)k=a-i+1;
                else{
                    k=min(b-i,i-a+1);
                }
                ans[(j-b)+k]++;
            }
        }
    }
    for(int i=1;i<=n-1;i++)cout<<ans[i]<<endl;
}

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

using namespace std;

int N,Q;
string s;
int lr[100000][2];
int ss[100000];

int main(){
    cin >> N >> Q;
    cin >> s;
    for(int i=0;i<Q;i++) cin >> lr[i][0] >> lr[i][1];
    int c = 0;
    ss[0] = 0;
    for(int i=1;i<N;i++){
        if(s[i-1] == 'A' && s[i] == 'C') c++;
        ss[i] = c;
    }
    for(int i=0;i<Q;i++){
        cout << ss[lr[i][1]-1] - ss[lr[i][0]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    double n,t,a;
    scanf("%lf %lf %lf",&n,&t,&a);
    double min=999999999;
    int ans=1;
    double h;
    int i;
    for(i=1;i<=n;i++){
        scanf("%lf",&h);
        if(fabs(a-(t-h*0.006))<min){
            min=fabs(a-(t-h*0.006));
            ans=i;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

sx, sy, tx, ty = getNM()

path = ""
path_s = ""
for _ in range(tx - sx):
    path_s += "R"
for _ in range(ty - sy):
    path_s += "U"
path_e = ""
for _ in range(tx - sx):
    path_e += "L"
for _ in range(ty - sy):
    path_e += "D"

path = path_s + path_e + "DR" + path_s + "UL" + "UL" + path_e + "DR"
print(path)

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


const int MAXN = 100 * 1000 + 10;
bool faux[MAXN];

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N , M;
	cin >> N >> M;
	int h[N];
	for (int i = 0 ; i < N ; i++)
	{
		cin >> h[i];
	}
	for (int i = 0 ; i < M ; i++)
	{
		int a,b;
		cin >> a >> b;
		a--; b--;
		if (h[a] <= h[b]) faux[a] = true;
		if (h[b] <= h[a]) faux[b] = true;
	}
	int nb = 0;
	for (int i = 0 ; i < N ; i++)
	{
		if (!faux[i]) nb++;
	}
	cout<<nb<<endl;
}

Measured memory_bytes: 4532
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

int k;
char str[1000];

int main()
{
    read(k);
    cin.getline(str,900);
    if((int)strlen(str)<=k) printf("%s",str);
    else {
        for (int i=0;i<k;++i) putchar(str[i]);
        printf("...");
    }
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int i=0;
    while(i+k<n){
        if(a[i]>=a[i+k]) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
        i++;
    }
    return 0;
}


Measured memory_bytes: 3972
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n, m;
vec<vi> s;
vi p; 
void in(){
    cin >> n >> m;
    rep(i,0,m){
        int cnt; cin >> cnt;
        vi tmp;
        rep(j,0,cnt) tmp.push_back(input() - 1);
        s.push_back(tmp);
    }
    rep(i,0,m) p.push_back(input());
}   

void solve(){

    int ans = 0;
    rep(i,0,(1 << n)){
        bool flag = true;
        rep(j,0,m){
            int cnt = 0;
            rep(k,0,sz(s[j])){
                if(i & (1 << s[j][k])) cnt++;
            }
            if(cnt % 2 != p[j]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    print(ans);

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

S, W = [int(x) for x in input().split()]

if S <= W:
    print("unsafe")
else:
    print("safe")


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


void solve(long long N, long long K, std::vector<long long> h){
    ll cnt = 0;
    for(ll i=0; i< N; i++){
        if(h[i]>= K) cnt ++;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N >> M;
  vvi mp(N+1,vi());
  rep(i,M){
    int a, b; cin >> a >> b;
    mp[a].push_back(b);
    mp[b].push_back(a);
  }
  vi rt(N+1,0);
  queue<int> que;
  que.push(1);
  
  while(!que.empty()){
    int a = que.front(); que.pop();
    rep(i,mp[a].size()){
      if(rt[mp[a][i]] == 0){
        rt[mp[a][i]] = a;
        que.push(mp[a][i]);
      }        
    }
  }
  cout << "Yes"<< endl;
  repa(i,2,N+1) COUT(rt[i]);
  return 0;
}


Measured memory_bytes: 12956
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define BSZ  __builtin_popcount
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const ll MOD = 2e18 + 100000;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

ll n, m, d, sum;

ll powmod(ll x, ll y, ll MODD = MOD) {
    if (y == 0) return 1LL;
    ll tmp = powmod(x, y / 2, MODD);
    tmp = sqr(tmp) % MODD;
    return (tmp * (y % 2 ? (x % MODD) : 1LL)) % MODD;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> d;
	if (d == 0)
		sum = (n - d) * (m - 1);
	else
		sum = 2LL * (n - d) * (m - 1);
	cout << fixed << setprecision(12) << (ld)sum / (ld)powmod(n, 2) << endl;
}


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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int m[n];
    for(int i=0; i<n; i++){
        cin >> m[i];
    }
    sort(m, m+n);
    int ans = 0;
    for(int i=0; i<k; i++){
        ans += m[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

int main(int argc, char const *argv[]) {
  int A=0,B=0;

  scanf("%d\n", &A);
  scanf("%d", &B);

  if((A==1&&B==2) || (A==2&&B==1))printf("3\n");
  if((A==2&&B==3) || (A==3&&B==2))printf("1\n");
  if((A==1&&B==3) || (A==3&&B==1))printf("2\n");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
using namespace std;
using ll=long long;

const int MXN=3005;

int n,ok[MXN][MXN][2],a[MXN];
ll memo[MXN][MXN][2];

ll dp(int l,int r,int p){
  if(l>r)return 0;
  if(ok[l][r][p])return memo[l][r][p];
  ok[l][r][p]=1;
  if(p)return memo[l][r][p]=min(dp(l+1,r,0)-a[l],dp(l,r-1,0)-a[r]);
  return memo[l][r][p]=max(dp(l+1,r,1)+a[l],dp(l,r-1,1)+a[r]);
}

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;++i)scanf("%d",a+i);
  printf("%lld\n",dp(1,n,0));
}


Measured memory_bytes: 211456
import math

# input an integer N
N = int(input())

n = math.log(N,10) + 1
int_n = int(n)

sum = 0
for i in range(1, int_n, 2):
    sum += 9 * math.pow(10, i-1)

if int_n % 2 != 0:
    sum += N - math.pow(10,int_n-1)+1

print(int(sum))

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int N=scan.nextInt();
        int M=scan.nextInt();
        int[] num_road=new int[N];
        int[] a=new int[M];
        int[] b=new int[M];
        int i;
        for(i=0;i<N;i++){
            num_road[i]=0;
        }
        for(i=0;i<M;i++){
            a[i]=scan.nextInt();
            b[i]=scan.nextInt();
            num_road[a[i]-1]++;
            num_road[b[i]-1]++;
        }
        for(i=0;i<N;i++){
            System.out.println(num_road[i]);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  map<Int, Int> cnt;
  for(Int a:as) cnt[a]++;

  Int sum=0;
  for(auto p:cnt)
    sum+=p.first*p.second;

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int b,c;
    cin>>b>>c;
    sum-=cnt[b]*b;
    sum-=cnt[c]*c;
    cnt[c]+=cnt[b];
    cnt[b]=0;
    sum+=cnt[b]*b;
    sum+=cnt[c]*c;
    cout<<sum<<newl;
  }

  return 0;
}


Measured memory_bytes: 10028
#include <stdio.h>

int main()
{

        int a,b;

        scanf("%d %d",&a,&b);
        if(a < b){
                printf("a < b\n");
        }

        else if(a > b){
                printf("a > b\n");
        }
        else{
                printf("a == b\n");
        }

        return 0;
}

Measured memory_bytes: 580
/**
 * Created by hiramekun at 20:58 on 2020-05-03.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, k;
    cin >> n >> k;

    vl snuke(n);
    rep(i, k) {
        ll d;
        cin >> d;
        rep(j, d) {
            ll a;
            cin >> a;
            a--;
            snuke[a]++;
        }
    }
    ll ans = 0;
    rep(i, n) {
        if (snuke[i] == 0) ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for(int i=a;i<a+k;i++) {
    if(i > b) {
      break;
    }
    cout << i << endl;
  }
  vector<int> ans(0);
  for(int i=b;i>b-k;i--) {
    if(i < a + k) {
      break;
    } else {
      ans.push_back(i);
    }
  }

  for(int i=ans.size()-1;i>=0;i--) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main{
    public static void main(String args[])  {

        HashSet<String> hs = new HashSet<String>();
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            hs.add(sc.next());
        }
        System.out.println(hs.size());
    }
}

Measured memory_bytes: 9556
#include<stdio.h>
#define NUM 100
void matrixChainOrder(int*);

int n1;
int main(){
  int p[NUM+1],p1,i;
  scanf("%d",&n1);
  scanf("%d%d",&p[0],&p[1]);
  for(i=2;i<=n1;i++){
    scanf("%d%d",&p1,&p[i]);
  }
  matrixChainOrder(p);
  return 0;
}


void matrixChainOrder(int *p){
  int m[n1+1][n1+1];
  int n,i,q,j,k,l;
  n=n1;
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=1000000;/*十分に大きな値*/
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>=q){
	  m[i][j]=q;
	}
      }
    }
  }
  printf("%d\n",m[1][n]);
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  cin >> str;
  bool flag = true;
  for (int i = 0; i < static_cast<int>(str.size()); ++i) {
    if (i % 2 == 0 && str[i] == 'L')
      flag = false;
    else if (i % 2 == 1 && str[i] == 'R')
      flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;




int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin >> x;
	ll p = 100; 
	int cnt = 0;
	while (p < x) {
		p += p / 100;
		cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <fstream>

using namespace std;


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

const string sep = " ";

class Compare {
public:
    bool operator()(int a, int b) {
        return a > b;
    }
};

std::vector<size_t> ZFunction(const std::string &text) {
    if (text.empty()) {
        return std::vector<size_t>();
    }
    std::vector<size_t> result(text.size());
    size_t left = 0;
    size_t right = 0;
    for (int i = 1; i < text.size(); ++i) {
        result[i] = std::max(0, std::min(static_cast<int>(right) - i,
                                         static_cast<int>(result[i - left])));
        while ((i + result[i] < text.size()) &&
               (text[result[i]] == text[i + result[i]])) {
            ++result[i];
        }
        if (i + result[i] > right) {
            left = i;
            right = i + result[i];
        }
    }
    return result;
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    set<string> S;
    int N;
    cin >> N;
    for (int i = 0;i < N; ++i){
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size();
    return 0;
}

Measured memory_bytes: 15728
int main(void){
	char str[200];
	scanf("%s",str);
	short str_length;
	for(str_length=0;str[str_length]!='\0';++str_length);
	//printf("test:%d\n", str_length);
	short length;
	length=str_length;
	short flag=0;
	if(length%2==0) length=str_length-2;
	if(length%2==1) length=str_length-1;
	short strstr=0;
	while(length>0){
		for(int i=0;i<length/2;i++){
			strstr=i+length/2;
			if(str[i]!=str[strstr]) flag=1;
		}
		if(flag==0) break;
		flag=0;length=length-2;
	}

	printf("%d",length);

	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= 100; ++i) {
        for (int j = 0; j <= 100; ++j) {
            if (i + j == X && 2*i + 4*j == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define watch(x) cerr <<"at line "<< __LINE__ <<", " << #x << " = " << x << "\n"
using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s.size() < 6) cout<<"NO"<<endl;
    else cout<< (((s[2] == s[3]) && (s[4] == s[5]))? "Yes" : "No");
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using mint = modint;



int main(){
	fastio;
	mint::set_mod(MOD);

	int n; cin>>n;
	int x[n], y[n];
	pair<int,p32> a[n];
	forn(i,n){
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
		a[x[i]] = mp(y[i],mp(y[i],i));
	}

	dsu d(n);
	priority_queue<pair<int,p32>> q;

	forn(i,n){
		int mi = a[i].fi;
		int ma = a[i].se.fi;
		int ind = a[i].se.se;
		while(!q.empty() && -q.top().fi<ma){
			auto t = q.top();
			d.merge(t.se.se,a[i].se.se);
			mi = min(mi, -q.top().fi);
			ma = max(ma, q.top().se.fi);
			q.pop();
		}
		a[i].fi = -mi;
		a[i].se.fi = ma;
		q.push(a[i]);
	}

	forn(i,n){
		cout<<d.size(i)<<ln;
	}


	return 0;
}

Measured memory_bytes: 8348
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;


template <class T>
T Swap(T &r, T &l) {
    T tmp = r;
    l = r;
    r = tmp;
}


ll cal(int len, int H, int W)
{
  ll ret = LLINF;
  ll a1 = 1LL * len * H;
  ll a2 = 1LL * (W - len) * (H / 2), a3 = 1LL * (W - len) * (H - (H / 2));
  ret = min(ret, max({ a1, a2, a3 }) - min({ a1, a2, a3 }));
 
  a2 = 1LL * H * ((W - len) / 2);
  a3 = 1LL * H * (W - len - (W - len) / 2);
  return min(ret, max({ a1, a2, a3 }) - min({ a1, a2, a3 }));
}



int main() {
    long w, h;
    cin >> h >> w;

    // h,wは10^5

    long smax;
    long smin;

    long smallS = LINF;

    for (int k = 0; k < 2; ++k) {
        // if (k == 1)Swap<long>(h, w);
        if (k==1){
        long tmp =h;
        h = w;
        w = tmp;
        }


        for (long i = 1; i <= h /2; ++i) {       /* code */
            // iを１つ目の分岐点とする.
            // long l = w / 2;
            // long l2 = w - l;
            // // long l2= w / 2 + w % 2;

            // long s1, s2, s3;
            // s1 = w * i;
            // s2 = (h - i) * l;
            // s3 = (h - i) * l2;

            // // smax = max(s3, max(s1, s2));
            // // smin = min(s3, min(s1, s2));
            // // // long s = abs(smax - smin);
            // smallS = min(smallS, max({s1,s2,s3} ) - min({s1,s2,s3}) );


            // long m = (h - i);
            // long m2 = m / 2;
            // long m3 = m - m2;
            // // s1 = w * i;
            // s2 = m2 * w;
            // s3 = m3 * w;


            // smallS = min(smallS, max({s1,s2,s3} ) - min({s1,s2,s3}) );

            smallS = min(smallS,(long)cal(i,w,h));
        }   

    }




    cout << smallS;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}
ll absol(ll x)
{
	if (x<0)
	{
		return -x;
	}
	return x;
}
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p%m)*(b%m))%m;
		b=((b%m)*(b%m))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll a[100002];
ll b[100002];
ll c[100002];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n,x=0,y=0,z=0,x1,y1,z1;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=n-1;i>=0;--i)
	{
		x1=x,y1=y,z1=z;
		x=a[i]+max(y1,z1);
		y=b[i]+max(x1,z1);
		z=c[i]+max(y1,x1);
	}
	x=max(x,y);
	cout<<max(x,z)<<"\n";
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  int N,M,X,ans=10000000;
  cin>>N>>M>>X;
  bool CAN=false;
  
  int C[N],A[N][M];
  REP(i,N){
    cin>>C[i];
    REP(j,M) cin>>A[i][j];
  }

  for(int bit=0; bit<(1<<N); ++bit){
    int cnt=0,AA[M];
    REP(i,M) AA[i]=0;
    bool SAFE=true;
    
    vector<int> S;
    for(int i=0; i<N; ++i){
      if(bit&(1<<i)) S.push_back(i);
    }
    
    REP(i,S.size()){
      REP(j,M) AA[j]+=A[S.at(i)][j];
      cnt+=C[S.at(i)];
    }
    
    REP(i,M){
      if(AA[i]<X) SAFE=false;
    }
    
    if(SAFE){
      if(ans>cnt) ans=cnt;
      CAN=true;
    }
  }
  
  if(CAN)cout<<ans<<endl;
  else cout<<-1<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#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;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000
#define N 400005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int x;
   cin>>x;
   int n=100;
   int cnt=0;
   while(n < x)
   {
       n+=(n/100);
       cnt++;
   }
   cout<<cnt<<endl;

}



Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		System.out.println(lcm(a, b));
	}

	static long lcm(int a, int b) {
		int temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}
}


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

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  
  unsigned long long count = 0;
  unsigned long long buf = 0;
  int c = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] == s[i-1]) {
      ++c;
      buf = buf + c;
    }
    else {
      if (buf != 0) {
        count += buf;
        buf = 0;
        c = 0;
      }
    }
  }
  count += buf;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, K;
    int l[50] = {};
    
    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> l[i];
    
    sort(l, l+N);
    reverse(l, l+N);
    
    int ans = 0;
    for(int i = 0; i < K; i++){
        ans += l[i];
    }
    
    cout << ans << endl;
    
}


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

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

    cin >> A >> B >> C;

    if (A > B){
        if(C > A){
            cout << "No" << endl;
        }else if (C < B){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(C < A){
            cout << "No" << endl;
        }else if (C > B){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char i[5];
    scanf("%s",i);
    if(strcmp(i,"SUN")==0)
        printf("7\n");
    if(strcmp(i,"MON")==0)
        printf("6\n");
    if(strcmp(i,"TUE")==0)
        printf("5\n");
    if(strcmp(i,"WED")==0)
        printf("4\n");
    if(strcmp(i,"THU")==0)
        printf("3\n");
    if(strcmp(i,"FRI")==0)
        printf("2\n");
    if(strcmp(i,"SAT")==0)
        printf("1\n");

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

void ABC129C()
{
	ll MOD = 1000000007;
	int N, M;
	cin >> N >> M;
	set<int> a;
	for (int i = 0; i < M; ++i)
	{
		int x;
		cin >> x;
		a.insert(x);
	}
	vl ct(N + 1);
	ct[0] = 1;
	ct[1] = a.find(1) == a.end() ? 1 : 0;

	for (int i = 2; i <= N; ++i)
	{
		ct[i] = a.find(i) == a.end() ? ct[i - 1] + ct[i - 2] : 0;
		ct[i] %= MOD;
	}

	cout << ct[N] << endl;
}
int main()
{
	ABC129C();
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

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

    int n; cin >> n;
    string s; cin >> s;

    vector<int> count(26);
    for (auto &c: s) count[c - 'a']++;
    mint ans = 1;
    for (auto e: count) ans *= e + 1;
    cout << ans - 1 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> V;
  
  while(n--){
    ll in;
    cin >> in;
    V.push_back(in);
  }

  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());

  ll ans = 1;

  for(int i = 0; i < V.size(); i++){
    if(V[i]-i/4 >= 0) ans += V[i]-i/4;
    else break;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

const int NMAX = 2500;
vii G[NMAX],RG[NMAX];
ll dist[NMAX];
int NN;
int visited[NMAX];


void add_edge(int a, int b, int w = 0) {
    G[a].emplace_back(b, w);
    RG[b].emplace_back(a,w);
}

/// BELMAN FORD //
/// find shortest path from s to all other nodes,
/// there can be negative weights and negative cycles
/// use with sparse graphs O(V*E); if modified using Adj Matrix O(V^3)
void bellman_ford(int s) {
    dist[s] = 0;
    FOR(i,NN-1) {
        FOR(j,NN) {
            if(dist[j] != INFL) {
                for(auto it : G[j]) {
                    if (visited[it.first]==2)
                        dist[it.first] = min(dist[it.first], dist[j] + it.second);
                }
            }
        }
    }
}
bool hasNegCycle() {
    FOR(j,NN) {
        if(dist[j] != INFL) {
            for(auto it : G[j]) {
                if (visited[it.first]==2 && dist[it.first] > dist[j] + it.second) return true;
            }
        }
    }
    return false;
}

void dfs0(int node=0){
    visited[node]=1;
    for(ii c:G[node]){
        if (visited[c.first]==0)
            dfs0(c.first);
    }
}

void dfs1(int node=NN-1){
    visited[node]++;
    for(ii c:RG[node]){
        if (visited[c.first]!=2)
            dfs1(c.first);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    int m,p;
    cin >> NN>>m>>p;
    fill(dist, dist + NN, INFL);
    FOR(i,m){
        int u,v,c;cin>>u>>v>>c;
        add_edge(u-1,v-1,p-c);
    }
    memset(visited,0,sizeof(visited));
    dfs0();
    dfs1();
    bellman_ford(0);
    cout << (hasNegCycle()?-1:max(0LL,-dist[NN-1]));

}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;
void File(){
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define ll long long
#define inf INT_MAX
const int maxn=5e5+10;
int n,m,x[maxn],y[maxn],a[maxn],fa[maxn],ans;
int find(int xx){return fa[xx]==xx ? xx : fa[xx]=find(fa[xx]);}
map<int,bool>mp[maxn];
int main(){
	//File();
	scanf("%d%d",&n,&m);
	REP(i,1,n)scanf("%d",&a[i]);
	REP(i,1,m)scanf("%d%d",&x[i],&y[i]);
	REP(i,1,n)fa[i]=i;
	REP(i,1,m){
		if(find(x[i])==find(y[i]))
			continue;
		int fx=find(x[i]),fy=find(y[i]);
		fa[fy]=fx;
	}
	REP(i,1,n){
		int f=find(i);
		mp[f][(int)i]=1;
	}
	REP(i,1,n){
		int f=find(i);
		if(mp[f][a[i]])
			++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 40320