akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>


void insertionSort(int A[],int N){
    int i,v,j;
    
    for(i=1;i<N;i++){
        v = A[i];
        j = i-1;
        
        while((j >= 0) && (A[j] > v)){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        
        
        for(j=0;j<N;j++){
            printf("%d",A[j]);
            if(j != N-1) printf(" ");
            else printf("\n");
        }
    }
}

int main(){
    int N,i;
    int A[1000];
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    
    for(i=0;i<N;i++){
        printf("%d",A[i]);
        if(i != N-1) printf(" ");
        else printf("\n");
    }
    
    insertionSort(A,N);
    
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> a(N);
  for (int i = 0; i < N; ++i) { std::cin >> a[i]; }
  int max_abs = 0;
  int max_abs_idx = 0;
  for (int i = 0; i < N; ++i) {
    if (max_abs < std::abs(a[i])) {
      max_abs = std::abs(a[i]);
      max_abs_idx = i;
    }
  }
  if (a[max_abs_idx] > 0) {
    std::cout << 2 * N << std::endl;
    std::cout << max_abs_idx + 1 << " " << 1 << std::endl;
    std::cout << max_abs_idx + 1 << " " << 1 << std::endl;
    for (int i = 1; i < N; ++i) {
      std::cout << i << " " << i + 1 << std::endl;
      std::cout << i << " " << i + 1 << std::endl;
    }
  } else if (a[max_abs_idx] < 0) {
    std::cout << 2 * N << std::endl;
    std::cout << max_abs_idx + 1 << " " << N << std::endl;
    std::cout << max_abs_idx + 1 << " " << N << std::endl;
    for (int i = N; i > 1; --i) {
      std::cout << i << " " << i - 1 << std::endl;
      std::cout << i << " " << i - 1 << std::endl;
    }
  } else {
    std::cout << 0 << std::endl;
  }
  return 0;
}

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

ll N;
vector<ll> X, S;

int main(void) {
  cin >> N;
  X.resize(N), S.resize(N);
  REP(i, 0, N) cin >> X[i] >> S[i];

  vector<ll> sum(N + 1, 0);
  REP(i, 0, N) sum[i + 1] = S[i];
  REP(i, 0, N) sum[i + 1] += sum[i];

  vector<ll> left(N + 1, 0);
  REP(i, 0, N) left[i + 1] = min(left[i], sum[i] - X[i]);

  ll ans = 0;
  REP(i, 0, N) {
    ll r = sum[i + 1] - X[i];
    ans = max(ans, r - left[i + 1]);
  }
  cout << ans << endl;
}


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

using i64 = int64_t;

int main(){
    i64 h, w;
    cin >> h >> w;
    if(h == 1 || w == 1)cout << 1 << endl;
    else cout << (((w+1)/2)*((h+1)/2) + (w/2)*(h/2)) << endl;

    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]

if N==1:
    print(abs(A[0]-X))
    exit(0)
for i in range(N):
    B.append(abs(X-A[i]))

a=gcd(B[0],B[1])
for i in range(2,N):
    a=gcd(a,B[i])
print(a)


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int N, K, S[102];

void solve() {
	for_(i,0,K) cin >> S[i];
	
	for_(i,0,N) for_(j,0,K) {
		int B;
		cin >> B;
		S[j] -= B;
	}
	
	bool flag = true;
	for_(i,0,K) flag &= (S[i] >= 0);
	puts(flag ? "Yes" : "No");
}

int main() {
	while (cin >> N >> K, N) {
		solve();
	}
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, N;
	cin >> n;
	int K[21];
	N = 1 << n;
	int t, k;
	int dif;
	bool flag;
	for(int i = 0; i <= 20; i++) K[i] = 0;
	for(int i = 0; i < N; i++) {
		cin >> K[0];
		k = 1;
		flag = false;
		while(1) {
			if(K[k] == 0) flag = true;
			dif = abs(K[k] - K[k - 1]);
			if(dif == 0) dif = K[k];
			K[k] = dif;
			K[k - 1] = 0;
			if(flag) break;
			k++;
		}
	}
	cout << K[n + 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define pii              pair <int,int>
#define debug(x) cerr << '>' << #x << ':' << x << endl;
//#pragma comment(linker, "/STACK:667772160")
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e18+99;
const int MOD=1e9+7;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
void boostIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int f(int x)
{
    if(x%100)
        return 0;
    return f(x/100)+1;
}
int32_t main(){
    boostIO();

    int d,n;
    cin>>d>>n;

    for(int i=1;;i++){
        if(f(i)==d){
            n--;
            if(n==0){
                cout<<i<<endl;
                return  0;
            }
        }
    }



}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int N;
int a[100], b[100], c[100], d[100];

int V;
vector<int> G[200];
int match[200];
bool used[200];

bool dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		int u = G[v][i], w = match[u];
		if (w < 0 || !used[w] && dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int solve() {
	int res = 0;
	fill(match, match + V, -1);
	for (int v = 0; v < V; v++) {
		if (match[v] < 0) {
			fill(used, used + V, false);
			if (dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

int main(void)
{

	cin >> N;
	V = 2 * N;

	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				G[i].push_back(j + N);
				G[j + N].push_back(i);
			}
		}
	}

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N, a, tmp;
  cin >> N >> a;
  rep (i, 4) {
    cin >> tmp;
    if (tmp < a) a = tmp;
  }
  long result = N / a;
  if (N % a != 0) result ++;
  cout << result + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n % 2 == 1)
		cout<<1.0*((n/2)+1)/n<<endl;
	else{
		cout<<1.0/2<<endl;
	}
	return 0;
}

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

int main(){
	
	string n;
	
	long sum=0;
	
	cin>>n;
	
	for( int i=0; i<n.size() ; i++ ){
		int temp = n[i]- '0';
		sum+=temp;
	}
	
	if( sum%9==0)cout<<"Yes";
	else cout<<"No";
	
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long int;
int main(){
    long int A, B, C;
    long int K;
    cin >> A >> B >> C >> K;
    if(A<B){
        if(K%2==0){
            cout << A-B << endl;
        }else if(K%2==1){
            cout << (A-B) * (-1) << endl;
        }
    }else if(A>B){
        if(K%2==0){
            cout << A-B << endl;
        }else if(K%2==1){
            cout << (A-B) * (-1) << endl;
        }
    }else if(A==B){
        cout << 0 << endl;
    }else if(abs(A-B)>1000000000000000000){
        cout << "Unfair" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
typedef unsigned long long ull ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int num[100]={0};

int main(){
	int N;
	ll x;
	cin >> N >> x;
	vector<ll> a(N);
	rep(i,N)cin>>a[i];
	ll ans=0;
	for(int i=1;i<N;i++){
		ll s=a[i]+a[i-1];
		if(s>x){
			ans=ans+(s-x);
			a[i]=max((ll)0,a[i]+x-s);
		}
	}
	cout<<ans<<endl;
	
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;

    vector<bool> has(N);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            a--;
            has[a] = 1;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (!has[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
/* h-ex9_1
   Ohshima */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 10

//スタックの定義
typedef struct stack{
  int size;
  int count;
  char data[SIZE];
  char *top;
}stack;

//スタックの初期化
void initialize_stack(stack *stk){
  stk->count = 0;
  stk->size = SIZE;
  stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
  if(stk->count >= stk->size){
    fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
    exit(1);
  }else{
    stk->top--;
    *(stk->top) = elem;
    stk->count++;
  }
}

//データの取り出し
void pop(stack *stk){
  if(stk->count <= 0){
    fprintf(stdout, "Error: stack underflow.\n");
    exit(1);
  }else{
    stk->top++;
    stk->count--;
  }
}

//スタックの中身を古いものから出力
void print_stack(stack *stk){
  int i;
  for(i = 0; i < stk->count; i++){
    putchar(stk->data[SIZE - 1 - i]);
  }
  printf("\n");
}

int main(void){
  stack stk;
  char tmp;
  int i;
  //スタックを初期化（ポインタ渡しで関数にわたすこと）
  initialize_stack(&stk);
  //1文字ずつ標準入力から受け取り以下を実行
  while(scanf("%c", &tmp) != EOF && tmp != '\n'){ //テストケースの中に10文字+改行文字の場合が含まれている
    //B以外の文字のときスタックにデータを追加
    if(tmp != 'B'){
      push(&stk, tmp);
    }else{
      //Bがきた場合、文字列が空でないならデータを取り除く
      if(stk.count > 0){
        pop(&stk);
      }
    }
  }
  //最後に、スタックに残っている文字を古いものから1文字ずつ出力
  print_stack(&stk);
  return 0;
}


Measured memory_bytes: 1516
#include<bits/stdc++.h>
using namespace std;
bool a[8];
int main(){
    int n;
    scanf("%d",&n);
    memset(a,false,sizeof(a));
    int ans=0;
    for(int i=0;i<n;i++){
        int temp;
        scanf("%d",&temp);

        if(temp<400)
            a[0]=true;
        else if(temp<800)
            a[1]=true;
        else if(temp<1200)
            a[2]=true;
        else if(temp<1600)
            a[3]=true;
        else if(temp<2000)
            a[4]=true;
        else if(temp<2400)
            a[5]=true;
        else if(temp<2800)
            a[6]=true;
        else if(temp<3200)
            a[7]=true;
        else ans++;
    }
    int x=0;
    for(int i=0;i<8;i++)
        if(a[i])
        x++;
    if(x==0){
        x=1;
        ans--;}
    printf("%d %d\n",x,x+ans);
}


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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int a, b, k, cnt;
   cin >> a >> b >> k;

   cnt = min(a, b);

   for (int i = cnt; i >= 1; --i)
   {
      if (a % i == 0 && b % i == 0)
      {
         --k;
      }
      if (k == 0)
      {
         cout << i << '\n';
         return 0;
      }
   }
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
s=[l[0]]
for i in range(1,n):
    s.append(s[i-1]+l[i])
x,y=0,0
for i in range(n):
    if s[i]*((-1)**i)<=0:
        x+=abs(s[i]-(-1)**i)
        s[i]=(-1)**i
    if i+1<=n-1:
        s[i+1]=s[i]+l[i+1]
s=[l[0]]
for i in range(1,n):
    s.append(s[i-1]+l[i])
for i in range(n):
    if s[i]*((-1)**(i+1))<=0:
        y+=abs(s[i]-(-1)**(i+1))
        s[i]=(-1)**(i+1)
    if i+1<=n-1:
        s[i+1]=s[i]+l[i+1]
print(min(x,y))

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

double n, eps = 1e-20;

int main() {
	cin >> n;
	repst(i,1,3500) {
		repst(j,1,3500) {
			double u = n*1.*i*1.*j;
			double l = 4*1.*i*1.*j - n*1.*i - n*1.*j;
			if (l!=0 && 1<=u/l && abs(round(u/l) - u/l) < eps) {
				cout << i << " " << j << " " << (int)(u/l) << ln;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
# encoding: "utf-8"

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def main():
    x, t = Stdin.read_line(converter=int)
    r = x - t
    if r < 0:
        r = 0
    print(r)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int n;
int a[20][20];
int bitdp[1<<17];
int dp[1<<17];
int dfs(int i){
   //cout<<i<<endl;
    int &ret=dp[i];
    if(ret!=-mod)return ret;
    ret=bitdp[i];
    for(int bit=i;bit>0;bit=(bit-1)&i){
        ret=max(ret,dfs(bit)+dfs(i&~bit));
    }
    return ret;
}
signed main(){
    cin>>n;
    rep(i,0,n)rep(j,0,n)cin>>a[i][j];
    rep(i,1,1<<n){
        vector<int>v;
        int ret=0;
        rep(j,0,n)if(i&1<<j)v.ps(j);
        for(auto e:v)for(auto k:v){
            if(e<=k)continue;
            ret+=a[e][k];
        }
        bitdp[i]=ret;
        dp[i]=-mod;
    }
    dp[0]=0;
    cout<<dfs((1<<n)-1)<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
long long n,k,s;
int main()
{
	cin>>n;
	for(int i=floor(sqrt(n));i>=1;i--)
	{
		if(n%i==0)
		{
			k=n/i;
			break;
		}
	}
	while(k>0)
	{
		s++;
		k/=10;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        List<int>[] neighbors;
        int[] values;

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Q = cin.ReadInt;

            values = new int[N];
            neighbors = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                values[i] = 0;
                neighbors[i] = new List<int>();
            }
            for (int i = 1; i < N; i++)
            {
                var a = cin.ReadInt - 1;
                var b = cin.ReadInt - 1;
                neighbors[a].Add(b);
                neighbors[b].Add(a);
            }
            for (int i = 0; i < Q; i++)
            {
                var p = cin.ReadInt - 1;
                var x = cin.ReadInt;
                values[p] += x;
            }
            Dfs(0, -1);

            Console.WriteLine(string.Join(" ", values));
        }

        void Dfs(int index, int parent)
        {
            foreach (int neighbor in neighbors[index])
            {
                if (neighbor == parent) continue;
                values[neighbor] += values[index];
                Dfs(neighbor, index);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 76424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
    int n,m; cin >> n >> m;
    vector<int> l(m); vector<int> r(m);
    for(int i=0;i<m;i++){
        cin >> l[i]>>r[i];
    }
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    int lmax = l[m-1];
    int rmin = r[0];
    int ans;
    ans = rmin - lmax+1;
    if(ans<0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  cin >> a >> b;
  if (b % a)
    cout << b - a << endl;
  else
    cout << a + b << endl;
}


Measured memory_bytes: 256
(let* ((w (read))
       (h (read))
       (n (read))
       (lst (loop repeat n
                  collect (list (read) (read) (read))))
       (x1 0)
       (x2 w)
       (y1 0)
       (y2 h))

  (defun adjust (ls)
    (let ((l (car ls)))

      ;(format t "l : ~A~%" l)

      (if (null ls)
        (format t "~A~%" (* (max (- x2 x1) 0) (max (- y2 y1) 0)))
        (cond ((= (caddr l) 1) (progn (setq x1 (max x1 (car l))) (adjust (cdr ls))))
              ((= (caddr l) 2) (progn (setq x2 (min x2 (car l))) (adjust (cdr ls))))
              ((= (caddr l) 3) (progn (setq y1 (max y1 (cadr l))) (adjust (cdr ls))))
              ((= (caddr l) 4) (progn (setq y2 (min y2 (cadr l))) (adjust (cdr ls))))))))

  (adjust lst))


Measured memory_bytes: 24564
from collections import Counter

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

cntA = Counter(A)
cntvalA = sorted(list(cntA.values()))
ans = sum(cntvalA[i] for i in range(len(cntvalA) - K))
print(ans)

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

int main(){
  long int n; cin>>n;
  int s=0,a;
  a = n;
  while(!(n/10 == 0 && n%10 == 0) ){
    s += n%10;
    n = n/10;
  }
  if(a%s==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if (a=="RRR")
		cout<<3<<endl;
	else if (a=="SRR"||a=="RRS")
		cout<<2<<endl;
	else if (a=="SSS")
		cout<<0<<endl;
	else
		cout<<1<<endl;
	return 0;
}


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


int main(){
  long long n, k, q;
  cin >> n >> k >> q;
  vector<long long> a(q);
  for(int i = 0; i < q; i++){
    cin >> a[i];
  }
  vector<long long> s(n);
  for(int i = 0; i < n; i++) s[i] = k - q;
  for(int i = 0; i < q; i++) s[a[i] - 1]++;
  for(int i = 0; i < n; i++){
    if(s[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4740
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long

int main() {
	LL t1, t2;
	LL a1, a2;
	LL b1, b2;

	cin >> t1 >> t2;
	cin >> a1 >> a2;
	cin >> b1 >> b2;
	if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
		cout << "infinity" << endl;
		return 0;
	}
	LL res = 0;
	if (a1 > b1 && a2 > b2) {
		cout << 0 << endl;
		return 0;
	}
	if (a1 < b1 && a2 < b2) {
		cout << 0 << endl;
		return 0;
	}
	if (a1 > b1) {
		swap(a1, b1);
		swap(a2, b2);
	}
	// now a1 < b1, a2 > b2
	LL sa1 = a1 * t1, sa2 = a2 * t2;
	LL sb1 = b1 * t1, sb2 = b2 * t2;
	if (sa1 + sa2 < sb1 + sb2) {
		cout << 0 << endl;
		return 0;
	}
	// now sa1 + sa2 > sb1 + sb2
	LL ds = sb1 - sa1;
	LL dts = sa1 + sa2 - sb1 - sb2;
	LL ans = (ds / dts) * 2 + 1;
	if (ds % dts == 0) {
		ans -= 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int max,min,i,j,n,R[200000];
   
  scanf("%d",&n);
  for(j=0;j<n;j++){
    scanf("%d",&R[j]);
  }
  min=R[0];
  max=R[1]-R[0];
   
  for(j=1;j<n;j++){
    if(max<R[j]-min)
      max=R[j]-min;
    if(min>R[j])
      min=R[j];
  }
  printf("%d\n",max);
  return 0;
   
}
 

Measured memory_bytes: 1376
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int state[300];
int I[1000], J[1000], K[1000], R[1000];

int main() {
    int a, b, c, N;
    while (cin >> a >> b >> c, a) {
        cin >> N;
        fill(state, state+300, 2);
        for (int i=0; i<N; ++i) {
            cin >> I[i] >> J[i] >> K[i] >> R[i];
            --I[i], --J[i], --K[i];
            if (R[i] == 1) {
                state[I[i]] = 1;
                state[J[i]] = 1;
                state[K[i]] = 1;
            }
        }
        for (int i=0; i<N; ++i) {
            if (R[i] == 0) {
                if (state[I[i]] == 1 && state[J[i]] == 1) {
                    state[K[i]] = 0;
                } else if (state[I[i]] == 1 && state[K[i]] == 1) {
                    state[J[i]] = 0;
                } else if (state[J[i]] == 1 && state[K[i]] == 1) {
                    state[I[i]] = 0;
                }
            }
        }
        for (int i=0; i<a+b+c; ++i) {
            cout << state[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1176
#pdf解説をそのまま
n = int(input())

c = [[0]*10 for _ in range(10)]

for i in range(10):
    for j in range(10):
        for k in range(1,n+1):
            if str(k)[0] == str(i) and str(k)[-1] == str(j):
                c[i][j] += 1
                
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)
    

Measured memory_bytes: 73860
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll, ll>> CB(M);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> CB[i].second >> CB[i].first;

  	sort(A.begin(), A.end());
    sort(CB.begin(), CB.end());
    reverse(CB.begin(), CB.end());
    ll ans = 0;
    ll tmp = 0;
    for (int i = 0; i < M; i++) {
        auto itr = upper_bound(A.begin(), A.end(), CB[i].first);
        ll cnt = itr - A.begin();
        //cout << cnt << " " << CB[i].second << endl;
        if (cnt - tmp <= 0) continue;
        cnt = min(cnt - tmp, CB[i].second);
        ans += cnt * CB[i].first;
        tmp += cnt;
        //cout << tmp << endl;
    }
    for (int i = tmp; i < N; i++) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 2560
#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;


ll grid[3010][3010] = {};
ll dp[3010][3010][4] = {};

int main() {
    int R, C, k;
    cin >> R >> C >> k;
    
    for (int i=0;i<k;i++) {
        int r, c;
        ll v;
        cin >> r >> c >> v;
        r--;
        c--;
        grid[r][c] = v;
    }

    
    dp[0][0][1] = grid[0][0];

    for (int r=0;r<R;r++){
        for (int c=0;c<C;c++){
            for (int i=0;i<4;i++){
                if (r+1<R){
                    dp[r+1][c][0] = max(dp[r+1][c][0],dp[r][c][i]);
                    dp[r+1][c][1] = max(dp[r+1][c][1],
                                        dp[r][c][i] + grid[r+1][c]);    
                }
                if (c+1<C){
                    dp[r][c+1][i] = max(dp[r][c+1][i], dp[r][c][i]);
                    if (i+1 <= 3){
                        dp[r][c+1][i+1] = max(dp[r][c][i] + grid[r][c+1],
                                              dp[r][c+1][i+1]);
                    }
                }
            }
        }
    }
    cout << *max_element(dp[R-1][C-1], dp[R-1][C-1]+4) << endl;
    return 0;

}

Measured memory_bytes: 356148
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  if(s.size()>9){cout<<"NO"<<endl;return 0;}
  //-KIH-B-R-
  s=regex_replace(s,regex("HB"),"HAB");
  s=regex_replace(s,regex("BR"),"BAR");
  if(s.size()==7){
    string f="KIHABAR";
    for(int i=0;i<7;i++){
      if(s.at(i) !=f.at(i)){cout<<"NO"<<endl;return 0;}
    }
    cout<<"YES"<<endl;
  }else if(s.size()==8){
    string h="AKIHABAR";string d="KIHABARA";bool y=true;bool n=true;
    for(int i=0;i<8;i++){
      if(s.at(i) !=h.at(i)){y=false;}
    }
    for(int i=0;i<8;i++){
      if(s.at(i) !=d.at(i)){n=false;}
    }
    if((n)||(y)){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
  }else if(s.size()==9){
    string m="AKIHABARA";
    for(int i=0;i<9;i++){
      if(s.at(i) !=m.at(i)){cout<<"NO"<<endl;return 0;}
    }
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Jan 27 14:25:28 2019
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	sum := 0
	left := 0
	ans := 0
	for i := range arr {
		for sum^arr[i] != sum+arr[i] {
			sum -= arr[left]
			left++
		}
		sum += arr[i]
		ans += i - left + 1
	}
	fmt.Println(ans)
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    string S;

    cin >> N >> S;

    vector<set<ll>> counts(26);
    REP(i, S.size()){
        char c = S[i];
        counts[c-'a'].insert(i);
    }

    ll Q;
    cin >> Q;

    REP(i, Q){
        ll q;
        cin >> q;
        if( q == 1 ){
            ll iq;
            char cq;
            cin >> iq >> cq;
            ll c = S[iq-1];
            counts[c-'a'].erase(iq-1);
            counts[cq-'a'].insert(iq-1);
            S[iq-1] = cq;
        }else {
            ll lq, rq;
            cin >> lq >> rq;
            ll chars = 0;
            REP(c,26){
                auto it = counts[c].lower_bound(lq-1);
                if( it != counts[c].end() ){
                    if( *it <= (rq-1) ){
                        chars++;
                    }
                }
            }
            cout << chars << endl;
        }

        /*
        REP(c,26){
            cout << char('a'+c);
            for( auto v: counts[c]){
                cout << v << " ";
            }
            cout << endl;
        }
        */
    }

}


Measured memory_bytes: 24196
n = int(input())
s = []
h = []
c = []
d = []
numbers = range(1, 14)
for _ in range(n):
  string, num = input().split()
  if "S" in string:
    s.append(int(num))
  elif "H" in string:
    h.append(int(num))
  elif "C" in string:
    c.append(int(num))
  else:
    d.append(int(num))
set_s = set(numbers) - set(s)
set_h = set(numbers) - set(h)
set_c = set(numbers) - set(c)
set_d = set(numbers) - set(d)
for element in sorted(set_s):
  print("S %d" % element)
for element in sorted(set_h):
  print("H %d" % element)
for element in sorted(set_c):
  print("C %d" % element)
for element in sorted(set_d):
  print("D %d" % element)


Measured memory_bytes: 5608
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
  int x = scan.nextInt();
  int y = scan.nextInt();
  int z = scan.nextInt();
  int temp= x;
  x = y;
  y = temp;
  temp = x;
  x = z;
  z = temp;
  System.out.println(x + " " + y + " " + z);
 }
}


Measured memory_bytes: 21460
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i) {
        if (i * 2 + (x - i) * 4 == y) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	double a, b, x; cin >> a >> b >> x;
	double v = a*a*b;
	double ans;
	if( x <= v/2 ){
		ans = a*b*b/2.0/x;
	} else {
		ans = 2.0*(v-x)/a/a/a;
	}
	cout << fixed << setprecision(10) << atan(ans)*180.0/acos(-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> h(N);
    vector<vector<ll>> m(N, vector<ll>());
    rep(i, N) cin >> h[i];
    rep(i, M){
        ll a, b; cin >> a >> b;
        m[--a].push_back(--b);
        m[b].push_back(a);
    }
    ll ans = 0;
    rep(i, N){
        bool ok = true;
        eachdo(m[i], e){
            if (h[i] <= h[e]){
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    pt(ans);
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i,n) {
    ll a,b;
    cin >> a >> b;
    ans += b-a+1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int dp[502][502];
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w", stdout);
	#endif
	int n,m,q;
	cin>>n>>m>>q;

	int l,r;
	for(int i=0;i<m;i++)
	{
		cin>>l>>r;
		dp[l][r]++;
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[i][j]+=dp[i][j-1];
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)dp[i][j]+=dp[i-1][j];
	//cout<<"ff";

	while(q--)
	{
		cin>>l>>r;


		cout<<dp[r][r]+dp[l-1][l-1]-(dp[l-1][r]+dp[r][l-1])<<"\n";
	}


	

}

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    if(a > c || b > c || a + b > c){
        cout << "No" << endl;
        return 0;
    }
    if((long long)(c-a-b)*(c-a-b) > (long long)4*a*b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main()
{
	int k, N,input,res=0;
	vector<int> n;

	cin >> N >>k;

	for (int i = 0; i < N; i++)
	{
		cin >> input;
		n.push_back(input);
	}

	sort(n.begin(), n.end(),greater<int>());

	for (int i = 0; i < k; i++)
	{
		res += n[i];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a+b>=10){
    cout<<"error"<<'\n';
  }
  else{
    cout<<a+b<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();  
        int b = sc.nextInt();  
        int c = sc.nextInt();  

        if(a + b == c || b + c == a || c + a == b ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
from collections import*
from itertools import*
from bisect import*
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
 
n,a,b,*v=map(int,open(0).read().split())
v=sorted(Counter(v).items(),reverse=1,key=lambda x:x[0])
vindex=[0]+list(accumulate(V for K,V in v))+[float("inf")]
#print(v,vindex)
lower=vindex[bisect_left(vindex,a)-1]
upper=vindex[bisect_left(vindex,a)]
count=0
ans=0
 
if a<=vindex[1]:
    ans=0
    for i in range(a,min(b,vindex[1])+1):
        ans+=cmb(vindex[1],i)
    print(float(v[0][0]))
    print(ans)
 
else:
    for s,t in v:
        count+=t
        if count>lower:
            ans+=s*(a-lower)
            break
        else:
            ans+=s*t
    print(ans/a)
    print(cmb(upper-lower,a-lower))

Measured memory_bytes: 3692
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
int sx,sy,ex,ey,n,size,sta[200010],f[200010];
long double pi=3.1415926535897932384626433832795028841971;
struct node
{
    int x,y;
};
long long cmax(long long pp,long long qq)
{
    if(pp>qq) return pp;
    return qq;
}
node a[200010];
bool cmp(node xx,node yy)
{
    return xx.x<yy.x;
}
int main()
{
    cin>>sx>>sy>>ex>>ey;
    cin>>n;
    if(sx>ex) swap(sx,ex),swap(sy,ey);
    for(int i=1;i<=n;++i)
        scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;++i)
   if((a[i].x>=sx&&a[i].x<=ex)&&((a[i].y>=sy&&a[i].y<=ey)||(a[i].y>=ey&&a[i].y<=sy)))
       f[++size]=a[i].y;
    if(sy>ey) for(int i=1;i<=size;++i)
        f[i]=-f[i];
    
    long long len = 0;
    memset(sta,0x3f,sizeof(sta));
    for(int i=1;i<=size;++i)
    {long p=lower_bound(sta+1,sta+size+1,f[i])-sta;
        sta[p]=f[i];
        len=cmax(len,p);
    }
    long double ans;
    ans=abs(sx-ex)+abs(sy-ey);
    ans=ans*100.0;
    ans+=(pi*5.0-20.0)*len;
    if(len==abs(ey-sy)+1||len==abs(ex-sx)+1) ans+=pi*5.0;
    printf("%.15Lf",ans);
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
          long long int a,b,i,x=0,c;
          cin>>a>>b;
          while(b--)
          {
                    cin>>c;
                    x=x+c;
          }
          if((a-x) < 0)
                   cout<<"-1"<<endl;
          else
                    printf("%d\n",a-x);
          return 0;
}


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

int CoinVariation(int a, int b, int c, int x){
  if(x % 50 != 0){
    return 0;
  }
  int counter = 0;
  for(int i = 0; i <= a; i++){
    int coin1 = x;
    if(coin1 - 500*i >= 0){
      coin1 -= 500*i;
    }else{
      break;
    }
    for(int j = 0; j <= b; j++){
      int coin2 = coin1;
      if(coin2 - 100*j >= 0){
        coin2 -= 100*j;
	  }else{
        break;
      }
      if(coin2 <= 50*c){
        counter++;
      }
    }
  }
  return counter;
};


int main(void){
    int a, b, c, x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    cout << CoinVariation(a, b, c, x);
};


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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 2e6 + 1;
int mod = 1e9 + 7;
int fact[MAX_N];
int tf[MAX_N];
int ts[MAX_N];

int gcd(int a, int b, int &x, int &y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int cnk(int n, int k) {
    int chisl = fact[n];
    int zn = fact[k] * fact[n - k];
    zn %= mod;
    int x, y;
    gcd(zn, mod, x, y);
    x %= mod;
    x += mod;
    x %= mod;
    return (chisl * x) % mod;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    string s;
    cin >> k >> s;
    int len = s.length();
    fact[0] = tf[0] = ts[0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
        tf[i] = tf[i - 1] * 25;
        tf[i] %= mod;
        ts[i] = ts[i - 1] * 26;
        ts[i] %= mod;
    }
    int ans = 0;
    for (int i = len - 1; i < len + k; ++i) {
        int t = (tf[i - len + 1] * ts[len + k - 1 - i]) % mod;
        t *= cnk(i, len - 1);
        t %= mod;
        ans += t;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 51308
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string.h>
#include <algorithm>
//#include <bits/stdc++.h>
#include    <vector>
#define INF 999999999
# include <cstdio>
# include <cstdlib>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int n ,k ,num=0, fa =0;
int main(){
   cin >>n;
   int sum=0;
   int odd[]={1,2,4,8,16,32,64,128};
   for(int i=1;i<=8;i++){
      if(odd[i]>n){
        num = odd[i-1] ;
         break;
      }
   }
   cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 3010
ll po[N];

ll n,dat[N],q;
ll ok[N][N],ng[N][N];
ll rui[N][N],zen;
ll oe[N][N],ne[N][N];

void eva(ll a,ll b){
    if(a>b)swap(a,b);
    ll dex=zen-rui[a][b];
    ok[a][b]=ok[a][b]*po[dex]%mod;
    ng[a][b]=ng[a][b]*po[dex]%mod;
    rui[a][b]=zen;
}

void upe(ll a,ll b){
    if(a>b)swap(a,b);
    ok[a][b]+=oe[a][b];ok[a][b]%=mod;oe[a][b]=0;
    ng[a][b]+=ne[a][b];ng[a][b]%=mod;ne[a][b]=0;
    rui[a][b]=zen;
}
void outs(ll a,ll b){
    eva(a,b);
    cout<<a+1<<" "<<b+1<<":"<<ok[a][b]<<" "<<ng[a][b]<<endl;
}
void oute(){
    outs(0,4);outs(1,2);
}

void upd(ll a,ll b){
    lol(i,n){
	eva(a,i);
	eva(b,i);
    }
    oe[a][b]=ng[a][b];
    ne[a][b]=ok[a][b];
    for(ll x=0;x<n;x++){
	if(x==a||x==b)continue;
	if(x<a){
	    oe[x][a]=ok[x][b];
	    oe[x][b]=ok[x][a];
	    ne[x][a]=ng[x][b];
	    ne[x][b]=ng[x][a];
	    continue;
	}
	if(b<x){
	    oe[a][x]=ok[b][x];
	    oe[b][x]=ok[a][x];
	    ne[a][x]=ng[b][x];
	    ne[b][x]=ng[a][x];
	    continue;
	}
	oe[a][x]=ng[x][b];
	oe[x][b]=ng[a][x];
	ne[a][x]=ok[x][b];
	ne[x][b]=ok[a][x];
    }
    zen++;
    lol(i,n){
	upe(a,i);
	upe(b,i);
    }
}
int main(){
    po[0]=1; for(ll i=1;i<N;i++)po[i]=po[i-1]*2%mod;
    
    cin>>n>>q;
    lol(i,n)scanf("%lld",&dat[i]);
    lol(i,n)lol(j,n){
	if(dat[i]==dat[j]){
	    ok[i][j]=ng[i][j]=0;
	    continue;
	}
	if(dat[i]<dat[j] xor i<j){
	    ok[i][j]=0,ng[i][j]=1;
	}
	else ok[i][j]=1,ng[i][j]=0;
	rui[i][j]=0;
    }
    zen=0;
    while(q--){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	a--,b--;
	upd(min(a,b),max(a,b));
    }
    ll ans=0;
    lol(i,n)lol(j,i){
	eva(j,i);
	ans=(ans+ng[j][i])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 309120