akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    priority_queue<ll> que;
    ll res=0;
    rep(i,n){
        if(i==0){
            que.push(a[i]);
            continue;
        }
        ll buf=que.top();que.pop();
        res+=buf;
        que.push(a[i]);que.push(a[i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 6856
#include<stdio.h>
int main(){
  int cards[4][13]={{0}};
  int n,i,x,j;
  char kind;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%c %d\n",&kind,&x);
    if(kind=='S'){
      cards[0][x-1]=1;
    }else if(kind=='H'){
      cards[1][x-1]=1;
    }else if(kind=='C'){
      cards[2][x-1]=1;
    }else{
      cards[3][x-1]=1;
    }
  }

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(cards[i][j]==0){
        if(i==0){
          printf("S %d\n",j+1);
        }else if(i==1){
          printf("H %d\n",j+1);
        }else if(i==2){
          printf("C %d\n",j+1);
        }else{
          printf("D %d\n",j+1);
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;

  cin >> n;
  ans = n + n * n + n * n * n;
  cout << ans << endl;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)

	fmt.Println(answer(h, w))
}

func answer(h int, w int) int {
	if h==1 || w==1 {
		return 1
	}
	if h%2 != 0 && w%2 != 0 {
		return (h*w+1)/2
	}
	return h*w/2
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000000];
int sum[1000000];
int n;
int main(){
 for (int i=2;i<1000000;i++){
  if (!a[i])
   for (int j=i*2;j<1000000;j+=i)
    a[j]=1;
 }
 for (int i=2;i<1000000;i++) sum[i]=sum[i-1]+(a[i]==0?1:0);
 while (cin>>n)
  cout<<sum[n]<<endl;
 return 0;
}

Measured memory_bytes: 10872
#include<stdio.h>
#include<stdlib.h>

 struct node{
   struct node *right;
   struct node *left;
   struct node *parent;
   int key;
};

typedef struct node * Node;

Node root = NULL;

void insert(int k)
{
  Node x = root;
  Node y = NULL;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL)
    {
      y = x;
      
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else x = x->right;
    }

  z->parent = y;

  if(y == NULL)root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;

  return;
}

void inorder(Node x)
{
  if(x != NULL)
    {
      inorder(x->left);
      printf(" %d", x->key);
      inorder(x->right);
    }
  return;
}

void preorder(Node x)
{
  if(x == NULL)return;

  printf(" %d", x->key);
  preorder(x->left);
  preorder(x->right);

  return;
}

Node treeSearch(Node x, int k)
{
  if(x == NULL || x->key == k)return x;
  // else if(x == NULL)return NULL;

  if(k < x->key)return treeSearch(x->left, k);
  else return treeSearch(x->right, k);
}

int main()
{
  int i;
  int m, k;
  char com[10];
  Node p;

  scanf("%d", &m);

  for(i = 0; i < m; i++)
    {
      scanf("%s", com);
      
      if(com[0] == 'i')
	{
	  scanf("%d", &k);
	  insert(k);
	}
      else if(com[0] == 'p')
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
      else if(com[0] == 'f')
	{
	  scanf("%d", &k);
	  p = treeSearch(root, k);
	  if(p == NULL)printf("no\n");
	  else printf("yes\n");
	}
    }
  
  return 0;
}



Measured memory_bytes: 20556
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int circle(double ra, double rb, double d){
	if((ra+rb)<d){
		return 0;
	}else{
		if(ra>(d+rb)){
			return 2;
		}else if(rb>(d+ra)){
			return -2;
		}else{
			return 1;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);

	double a[2], b[2];
	double ra, rb;

	int n;
	scanf("%d", &n);

	while(n--){
		scanf("%lf %lf %lf %lf %lf %lf", &a[0], &a[1], &ra, &b[0], &b[1], &rb);

		double d=sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]));

		printf("%d\n", circle(ra, rb, d));
	}
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <atcoder/twosat>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  using namespace atcoder;
  
  int n, d;
  cin>>n>>d;
  int x[n], y[n];
  REP(i, n) cin>>x[i]>>y[i];
  
  two_sat ts(2 * n);
  REP(i, n){
    ts.add_clause(i, true, i + n, true);
    ts.add_clause(i, false, i + n, false);
  }
  REP(i, n){
    for(int j = i + 1; j < n; j++){
      if(abs(x[i] - x[j]) < d) ts.add_clause(i, false, j, false);
      if(abs(x[i] - y[j]) < d) ts.add_clause(i, false, j + n, false);
      if(abs(y[i] - x[j]) < d) ts.add_clause(i + n, false, j, false);
      if(abs(y[i] - y[j]) < d) ts.add_clause(i + n, false, j + n, false);
    }
  }
  bool possible = ts.satisfiable();
  if(!possible){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  vector<bool> ans = ts.answer();
  REP(i, n){
    if(ans[i]){
      cout << x[i] << endl;
    }else{
      cout << y[i] << endl;
    }
  }    
  return 0;
}


Measured memory_bytes: 3828
n = int(input())

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

mv = 0
ans = [0]
for i in range(n-1):
    if h[i+1] <= h[i]:
        mv += 1
        #print("i",i)
    else:
        ans.append(mv)
        #print("mv",mv)
        mv = 0
if mv != 0:
    ans.append(mv)
        
print(max(ans))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n,used[1010],sum=0;
queue<ll> Q[1010],m;


void init(){
	cin>>n;
	rep(i,n){
		rep(j,n-1){
			ll a;
			cin>>a;
			Q[i].push(a-1);
		}
	}
	rep(i,n)m.push(i);
	rep(i,n)used[i]=-1;
}

int main(void){
	init();
	ll ans;
	for(ans=0;;ans++){
		bool ok=false;
		queue<ll> m2;
		while(!m.empty()){
			ll p = m.front();
			m.pop();
			if(used[p]!=ans && !Q[p].empty()){
				ll q = Q[p].front();  // pの行き先
				if(used[q]!=ans && !Q[q].empty() && p==Q[q].front()){
					Q[p].pop();
					Q[q].pop();
					sum+=2;
					used[p]=ans;
					used[q]=ans;
					m2.push(p);
					m2.push(q);
					ok=true;
				}
			}
		}
		if(!ok)break;
		m=m2;
	}
	if(sum!=n*(n-1))ans=-1;
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

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

    vector<ll> h(N);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }

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

    ll ans = h[N-1]-h[0];
    for(int i=0;i<=N-K;i++){
        ll diff = h[i+K-1]-h[i];
        if(diff < ans){
            ans = diff;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200005

// it's swapnil07 ;)

int arr[MAXN];
int mintree[4*MAXN];
int tree[4*MAXN];
int asc[MAXN];

void build_min(int index, int l, int r){
    if(l>r){
        return;
    }
    if(l==r){
        mintree[index]=arr[l];
        return;
    }
    int mid = (l+r)>>1;
    build_min(2*index, l, mid);
    build_min(2*index+1, mid+1, r);
    mintree[index]=min(mintree[2*index], mintree[2*index+1]);
}

int query_min(int index, int x, int y, int l, int r){
    if(y<x || r<l || l>y || r<x){
        return INF;
    }
    if(x<=l && y>=r){
        return mintree[index];
    }
    int mid = (l+r)>>1;
    int z1 = query_min(2*index, x, y, l, mid);
    int z2 = query_min(2*index+1, x, y, mid+1, r);
    return min(z1, z2);
}


void build(int index, int l, int r){
    if(l>r){
        return;
    }
    if(l==r){
        tree[index]=arr[l];
        return;
    }
    int mid = (l+r)>>1;
    build(2*index, l, mid);
    build(2*index+1, mid+1, r);
    tree[index]=max(tree[2*index], tree[2*index+1]);
}


int query(int index, int x, int y, int l, int r){
    if(y<x || r<l || l>y || r<x){
        return 0;
    }
    if(x<=l && y>=r){
        return tree[index];
    }
    int mid = (l+r)>>1;
    int z1 = query(2*index, x, y, l, mid);
    int z2 = query(2*index+1, x, y, mid+1, r);
    return max(z1, z2);
}

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n, k; cin>>n>>k;
    For(i, 0, n){
        cin>>arr[i];
    }
    build_min(1, 0, n-1);
    build(1, 0, n-1);

    asc[0] = 0;
    For(i, 1, n){
        if(arr[i]>arr[i-1])
            asc[i]=asc[i-1]+1;
        else
            asc[i]=0;
    }
    int ct = 0;
    For(i, k-1, n){
        if(asc[i]==k-1){
            ct++;
            continue;
        }
    }
    int ans = n-k+1;
    For(i, k, n){
        int sp = i-k;
        int ep = i;
        int minv = query_min(1, sp, ep, 0, n-1);
        int maxv = query(1, sp, ep, 0, n-1);
        if(minv == arr[sp] && maxv==arr[ep])
            ans--;
    }
    ans -= ct;
    if(ct > 0)
        ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 16000
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, m;
vector<int> graph[100001];
int qr[100000][3];
int color[100001];
bool visit[100001][11];
int nowcolor;

void recur(int u, int d) {
	if (visit[u][d]) return;
	visit[u][d] = true;
	if (d == 0) {
		color[u] = nowcolor;
		return;
	}

	recur(u, d - 1);
	for (int v : graph[u]) {
		recur(v, d - 1);
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d %d", &a, &b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		scanf("%d %d %d", &qr[i][0], &qr[i][1], &qr[i][2]);
	}
	for (int i = q - 1; i >= 0; --i) {
		nowcolor = qr[i][2];
		recur(qr[i][0], qr[i][1]);
	}

	for (int i = 1; i <= n; ++i) {
		printf("%d\n", color[i]);
	}
	return 0;
}

Measured memory_bytes: 9080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<4){
    a=(4-a)*100000;
  }else{
    a=0;
  }
  if(b<4){
    b=(4-b)*100000;
  }else{
    b=0;
  }
  PRN(a+b+(a==300000&&b==a)*400000);
  return 0;
}


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

int main(){

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

    vector<vector<int>> A(n);
    for(int i = 0; i < q; ++i){
        int com, t;
        cin >> com >> t;
        if(com == 0){
            int x;
            cin >> x;
            A[t].push_back(x);
        }
        else if(com == 1){
            for(int i = 0; i < A[t].size(); ++i){
                cout << A[t][i];
                if(i != A[t].size()-1){
                    cout << " ";
                }
            }
            cout << endl;
        }
        else if(com == 2){
            A[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5752
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n,p,maxp=0,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p;
        sum+=p;
        maxp=max(maxp,p);
    }
    cout<<sum-maxp/2<<endl;
}


Measured memory_bytes: 256
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long lint;
int main(){
    int k;
    int n;
    cin >> k;
    cin >> n;
    vector<int> a(n);
    REP(i,n)
        cin >> a[i];
    vector<int> des(n);
    REP(i,n){
        if(i == n - 1){
            des[i] = a[0] + (k - a[i]);
        }else
            des[i] = a[i + 1] - a[i];
    }
    int max = 0;
    REP(i,n){
        if(des[i] > max)
            max = des[i];
    }

    cout << k - max << endl;
    
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

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

	int l = 0;
	int r = n-1;

	int ans = 0;
	while (r > l){
		if (s[r] == 'W') {
			r--; continue;
		}
		if (s[l] == 'R') {
			l++; continue;
		}

		ans += 1;
		swap(s[l], s[r]);
		r--;
		l++;
	}

	cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3772
N,M = map(int,input().split())

List = list(map(int,input().split()))
List.sort()

sa = []

for i in range(M-1):
  a = List[i+1] - List[i]
  sa.append(a)
  
sa.sort()
l = len(sa)

if N >= M:
  print(0)
else:
  print(sum(sa[:l-N+1]))


Measured memory_bytes: 13968
import javax.swing.plaf.nimbus.NimbusStyle;
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int D = Integer.parseInt(sc.get());
		int T = Integer.parseInt(sc.get());
		int S = Integer.parseInt(sc.get());
		System.out.println(S * T >= D ? "Yes" : "No");
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32804
#! /usr/local/bin/python3
# coding: utf-8

def swap(A, i, j):
    tmp = A[i]
    A[i] = A[j]
    A[j] = tmp

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            swap(A, i, j)
    swap(A, i + 1, r)
    return i + 1

def bracketify(A, i, q):
    return "[" + str(A[i]) + "]" if i == q else str(A[i])

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    q = partition(A, 0, n - 1)
    print(*[bracketify(A, i, q) for i in range(n)])

main()



Measured memory_bytes: 16656
#include<stdio.h>
#include<stdlib.h>
int selectionSort(int *,int);
void swap(int *,int *);
int main(){
  int i,n,*m,count;
  scanf("%d",&n);
  m = (int *)malloc(n * sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&m[i]);
  }
  count = selectionSort(m,n);
  for(i=0;i<n;i++){
    printf("%d",m[i]);
    if(i!=n-1){
      printf(" ");
    }
    else printf("\n");
  }
  printf("%d\n",count);
  return 0;
}

int selectionSort(int *m,int n){
  int count=0,i,j,minj;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(m[j]<m[minj]){
        minj = j;
      }
    }
    if(minj!=i){
      swap(&m[i],&m[minj]);
      count++;
    }
  }
  return count;
}

void swap(int *x,int *y){
  int r;
  r=*x;
  *x=*y;
  *y=r;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  cout << 48 - n << endl;
}

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


const int MOD = 1e9 + 7;
int H, W, K;
vector<int> fib;
ll ans;


void input() {
    cin >> H >> W >> K;
}


int solve(int n) {
    if (n < 0) return 1;
    return fib[n];
}


int main() {
    input();
    fib = vector<int>(W);
    fib[0] = 1;
    fib[1] = 2;
    for (int i = 2; i < W; i++) fib[i] = fib[i-1] + fib[i-2];
    vector<ll> w1, w2;
    w1 = vector<ll>(W, 0);
    w1[0] = 1;
    rep(i, H) {
        w2 = vector<ll>(W, 0);
        for (int j = 0; j < W; j++) {
            if (j > 0) w2[j-1] = (w2[j-1] + w1[j] * solve(j-2) * solve(W-j-2)) % MOD;
            w2[j] = (w2[j] + w1[j] * solve(j-1) * solve(W-j-2)) % MOD;
            if (j < W - 1) w2[j+1] = (w2[j+1] + w1[j] * solve(j-1) * solve(W-j-3)) % MOD;
        }
        w1 = w2;
    }
    cout << w1[K-1] << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
plis = list(map(int, input().split()))
plis = list(map(lambda p : (1+p)/2, plis))
slis = [plis[0]]
for i in range(1, n):
    slis.append(slis[-1] + plis[i])
ans = slis[k-1]
for i in range(n-k):
    ans = max(ans, slis[i+k] - slis[i])
print(ans)

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

using vqi=vector<queue<int>>;
using vpi=vector<pii>;
using bs=bitset<60>;
using vbi=vector<bs>;
constexpr ll MOD = 1e9 + 7;

struct node {
    int up;
    vi down;
    int from_v;
    int from_u;
};

int main() {
    int N, u, v;
    cin >> N >> u >> v;

    using vn=vector<node>;
    map<int, vi> m;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        m[a].emplace_back(b);
        m[b].emplace_back(a);
    }

    vn nodes(N + 1);
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int top = q.front();
        q.pop();
        for (int item:m[top]) {
            if (nodes[top].up != item) {
                nodes[top].down.emplace_back(item);
                nodes[item].up = top;
                nodes[item].from_v = nodes[top].from_v + 1;
                q.push(item);
            }
        }
    }

    /*
    for (int i = 1; i <= N; i++) {
        cout << i << ": " << nodes[i].up << ", ";
        for (int item:nodes[i].down) {
            cout << item << " ";
        }
        cout << "::" << nodes[i].from_v << endl;
    }
     */

    int max_d = nodes[u].from_v;

    vn nodes2(N + 1);
    q = queue<int>();
    q.push(u);
    while (!q.empty()) {
        int top = q.front();
        q.pop();
        for (int item:m[top]) {
            if (nodes2[top].up != item) {
                nodes2[top].down.emplace_back(item);
                nodes2[item].up = top;
                nodes2[item].from_u = nodes2[top].from_u + 1;
                if (nodes2[item].from_u < nodes[item].from_v) {
                    q.push(item);
                    max_d = max(max_d, nodes[item].from_v);
                }
            }
        }
    }

    cout << max_d - 1 << endl;

    /*
    for (int i = 1; i <= N; i++) {
        cout << i << ": " << nodes2[i].up << ", ";
        for (int item:nodes2[i].down) {
            cout << item << " ";
        }
        cout << "::" << nodes2[i].from_u << endl;
    }
    */
    return 0;
}


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

#define ll long long int

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i,j;
    cin>>n;
    vector<ll> arr(n);
    unordered_map<ll,ll> umap;
    for(i=0;i<n;i++) {
        cin>>arr[i];
        if(umap.find(i+1+arr[i]) == umap.end())
            umap[i+1+arr[i]] = 1;
        else
            umap[i+1+arr[i]] += 1;
    }

    ll ans=0;
    for(i=0;i<n;i++) {
        if(i+1-arr[i] >= 2 && umap.find(i+1-arr[i]) != umap.end())
            ans += umap[i+1-arr[i]];
    }
    cout<<ans<<"\n";
    
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  string s , t  ;
  cin >> s >> t ;
  deque<char> S , T ;
  rep(i,n){
    S.push_back(s.at(i)) ;
    T.push_back(t.at(i));
  }
  if(s == t ) {
    cout << s.size() <<endl ; 
    return 0 ;
  }
  
  int ans = 2 * n ;
  
  rep(i,n){
    S.pop_front();
    T.pop_back();
    
    if( S == T){
      ans = S.size() + 2*(i+1) ;
      cout <<  ans <<endl ;
      return 0 ;
    }
  }
    
  
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    if((b/k)-((a-1)/k)>0) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main { //クラス名はMain
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String raw = sc.next();
        int x = Integer.parseInt(raw);
        int s = x % 60;
        int m = x / 60;
        int h = m / 60;
        m = m % 60;
        System.out.printf("%d:%d:%d\n", h, m, s);
        
    }
}


Measured memory_bytes: 26464
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    X, t = map(int, input().split())
    
    print(max(X - t, 0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10312
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll ar[200007],a,b, test, sum,t,x=0,p,q,y,i,j,k=0,l,cnt;
ll br[200007];
string s,s1,s2;

int main()
{
    ll test;
    cin>>s;
   for(int i=0;i<s.size();i++)
    cout<<"x";


}


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

string but[10] = {" ", "',.!?", "abcABC", "defDEF", "ghiGHI",
                  "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV",
                  "wxyzWXYZ" };

string conv(string &s,int p,int st) {
    if(p == s.length()) return "";
    int cnt = 0;
    while(p < s.length() && s[p] == st + '0') cnt++,p++;

    return string((st==0)?(cnt-1):1,but[st][(cnt-1)%(but[st].length())])
        + conv(s,p,s[p]-'0');
}

int main() {
    string s;
    while(cin>>s) cout<<conv(s,0,s[0]-'0')<<endl;
}

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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	if(a >= 13) cout << b << endl;
	else if(a >= 6 && a<= 12) cout << b/2 << endl;
	else if(a <= 5) cout << 0 << endl;
	
	
	return 0;
}


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

int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  vector<int> cnt(N);
  
  for(int i=1;i<N;i++){
    for(int j=i+1;j<=N;j++){
      int k;
      k=min(j-i,abs(i-X)+abs(j-Y)+1);
      cnt[k]++;
    }
  }
    for(int i=1;i<N;i++){
      cout << cnt[i] << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int h, n, k;
	cin >> h >> n >> k;
	vector<vector<ll>> table(n, vector<ll>(n));
	rep(bit, 1 << (n - 1)) {
		vector<int> a(n - 1);
		int p = bit;
		rep(i, n - 1) {
			if (p & 1) a[i] = 1;
			p >>= 1;
		}
		bool flag = 0;
		rep(i, n - 2) {
			if (a[i] + a[i + 1] == 2) flag = 1;
		}
		if (flag) continue;
		vector<int> T(n);
		rep(i, n) T[i] = i;
		rep(i, n - 1) {
			if (a[i] == 1) swap(T[i], T[i + 1]);
		}
		rep(i, n) table[i][T[i]]++;
	}
	vector<vector<ll>> dp(h + 1, vector<ll>(n));
	dp[0][0] = 1;
	rep(i, h) rep(j, n) rep(k, n) dp[i + 1][k] = (dp[i + 1][k] + dp[i][j] * table[j][k] % MOD) % MOD;
	cout << dp[h][k - 1] << endl;
	return 0;
}

Measured memory_bytes: 3608
//itp1_3-c
#include <iostream>
using namespace std;

int main(){
 int x,y;
 while(true){
  cin>>x>>y;
  if(!x && !y)
   break;
  else
   cout<<min(x,y)<<" "<<max(x,y)<<endl;
 }
 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

using T = tuple<ll, ll, ll>;

int main(){

  ll n = in();
  vector<T> s(n);
  REP(i, n){
    ll a = in();
    ll b = in();
    s[i] = T(a+b, a, b);
  }
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());

  ll ans = 0;
  REP(i, n){
    ll c, a, b;
    tie(c, a, b) = s[i];
    if(i % 2 == 0){
      ans += a;
    } else {
      ans -= b;
    }
  }

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


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

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

		long a[] = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long s[] = new long[n + 1];
		s[0] = a[0];

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

		Arrays.sort(s);

		Map<Long, Long> map = new HashMap<>();

		for (int i = 0; i < n; i++) {
			if (map.containsKey(s[i])) {
				map.put(s[i], map.get(s[i]) + 1);
			} else {
				map.put(s[i], 1L);
			}
		}

		long ans = 0;

		int m = 1;
		for (int i = 0; i < n; i++) {
			if (s[i] == s[i + 1]) {
				m++;
			} else {
				m = 1;
			}
			ans += m - 1;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 72528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  string str;
  cin >> str;
  int arr[26]={0};
  for(int i=0;i<str.length();i++)
  {
    arr[str[i]-'a']++;
  }
  int index=-1;
  for(int i=0;i<26;i++)
  {
    if(arr[i]==0){
      index=i;
      break;
    }
  }
  if(index==-1)
    cout << "None" << endl;
  else
    cout << char(index+97) << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int a,b ,c;
    cin >> a >> b >> c;
    bool flg=true;
    if(a==b&&b==c)flg=false;
    if(a!=b&&b!=c&&c!=a)flg=false;
    if(flg)puts("Yes");
    else puts ("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int dp[10000][8],n,a[10000];string S;
int main(){
	cin>>n>>S;dp[0][1]=1;
	for(int i=0;i<S.size();i++){
		if(S[i]=='J')a[i]=0;
		if(S[i]=='O')a[i]=1;
		if(S[i]=='I')a[i]=2;
	}
	for(int i=0;i<S.size();i++){
		for(int j=0;j<8;j++){
			int G[3]={j%2,(j/2)%2,j/4};
			for(int k=0;k<8;k++){
				int H[3]={k%2,(k/2)%2,k/4};
				if(H[a[i]]==0)continue;
				int V=0;
				for(int l=0;l<3;l++){
					if(G[l]==1 && H[l]==1)V=1;
				}
				dp[i+1][k]+=dp[i][j]*V;dp[i+1][k]%=10007;
			}
		}
	}
	int sums=0;for(int i=0;i<8;i++)sums+=dp[n][i];
	cout<<sums%10007<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

char pp[1000000] = {};

int
main(int argc, char *argv[])
{
  int n, k, h, ans = 0;
  scanf("%d %d", &n, &k);
  rep(i, n) {
    scanf("%d", &h);
    if (h >= k) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
MOD = 10**9+7

c = [0]*(K+1)
for i in range(1, K+1)[::-1]:
    c[i] = pow(K//i, N, MOD)
    for j in range(i*2, K+1, i):
        c[i] -= c[j]
        if c[i]<0:
            c[i] += MOD

ans = 0
for i in range(1, K+1):
    ans += i*c[i]
ans %= MOD

print(ans)

Measured memory_bytes: 69072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15 {
    class Program {
        static void Main(string[] args) {
            //入力
            string s = Console.ReadLine();
            int N = int.Parse(s.Split(' ')[0]);
            int K = int.Parse(s.Split(' ')[1]);

            string S = Console.ReadLine();

            //文字列の分割
            string s1 = S.Substring(0, K - 1);
            string s2 = S.Substring(K - 1, 1);
            s2 = s2.ToLower();
            string s3 = S.Substring(K, N - K);

            //実行


            //出力
            Console.WriteLine(s1 + s2 + s3);

        }
    }
}


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

int main() {
  int n; cin >>n;
  int height[n];
  for (int i = 0; i < n; i++) cin >> height[i];
  int dp[n]; 
  dp[0] = 0; 
  dp[1] = abs(height[1]-height[0]);
  for (int i = 2; i < n; i++)
    dp[i] = min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]));
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s.size() == 2)
		cout << s << endl;
	else if(s.size() == 3)
	{
		reverse(s.begin(), s.end());
		cout << s << endl;
	}
	return 0;
}



Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<queue>
#include<stack>
#include<list>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ll,ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)


//#define min(a,b) a>b?b:a
//#define max(a,b) a>b?a:b
#define all(arr) arr.begin(),arr.end()
//#define sort(vec) sort(vec.begin(),vec.end())
//#define reverse(vec) reverse(vec.begin(),vec.end())


ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a);
        a = (a*a);
        b = b/2;
    }
    return ans;
}

ll gcd(ll a,ll b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}

ll dp[105][100005];

signed main()
{
    fastio;
    
    ll n,W;
    cin >> n >> W;
    
    for(int i = 0;i<=n;i++)
    {
        for(int j = 0;j<=1e5;j++)
        {
            dp[i][j] = intinf;
        }
    }
    dp[0][0] = 0;
    
    vector<ll> w(n+1);
    vector<ll> v(n+1);
    
    for(ll i = 1;i<=n;i++)
    {
        cin >> w[i] >> v[i];
    }
    
    ll ans = 0;
    
    for(int i = 1;i<=n;i++)
    {
        for(int j = 0;j<=1e5;j++)
        {
            if(j >= v[i])
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i]] + w[i]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    
    for(ll i = 0;i<=1e5;i++)
    {
        if(dp[n][i] <= W)
            ans = max(ans,i);
    }
    
    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
//main
signed main(){
  int N,M,O,P,Q,count=0,count2=0,count3=0;
  double D=0;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>S;
  if(S=="Sunny")cout<<"Cloudy"<<endl;
  elif(S=="Cloudy")cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
}


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

using namespace std;

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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());

	cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
const int N=2e5+5;
ll a[N],ans[N];
vll g[N];
multiset < int > s;
multiset < int > :: iterator it;
void dfs(ll u,ll par=-1){
	s.insert(a[u]);
    
    it = s.lower_bound(a[u]);
    ll del=-1;
	if(++it != s.end()) {
        s.erase(it);
        del=*it;
      }
      
      ans[u]=s.size();
      
      for(auto i:g[u]){
      	if(i==par)
      	continue;
      	dfs(i,u);
      }
      
      if(del!=-1)
      s.insert(del);
      
      s.erase(s.find(a[u]));
}

int32_t main()
{
    
	fast
	ll n;
	cin>>n;
	f(i,n)
	cin>>a[i];
	
	f(i,n-1){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
		
		
	}
	
	dfs(0);
	f(i,n)
	cout<<ans[i]<<nl;

	return 0;
    
}

Measured memory_bytes: 32088
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N = int(single_input())
    sum = 0
    smallestB = 10 ** 20
    for i in range(N):
        a, b = map(int, line_input())
        sum += a
        if a > b: smallestB = min(smallestB, b)
    print(max(0, sum - smallestB))
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
//abc128_a.cpp
//Sun May 26 20:47:14 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,p;
	cin >> a >> p;

	cout << (3*a+p)/2 << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
s = gets.to_i
arr = []
i = 1
loop do
    if arr.include?(s) then
        puts i
        break
    end
    arr.push(s)
    if s % 2 == 0 then
        s = s / 2
    else
        s = s * 3 + 1
    end
    i = i + 1
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main (){
    int N, M; cin >> N >> M;
    vector<PLL> D(N);
    for(int i=0; i<N; i++){
        ll A, B; cin >> A >> B;
        D[i] = PLL(A, B);
    }
    
    sort(D.begin(), D.end());
    
    ll cnt = 0;
    ll sum = 0;
    for(int i=0; i<N; i++){
        ll a = D[i].first;
        ll b = D[i].second;
        if(cnt + b > M){
            sum += (M - cnt) * a;
            cnt += M - cnt;
            break;
        } else {
            cnt += b;
            sum += a*b;
        }
    }
    
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    long long int n, cnt = 0;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i<n ;i++){
        cin >> v[i];
        cnt += v[i];
    }
    
    cout << cnt - *(max_element(v.begin(), v.end())) / 2 << endl;

}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<pair<int,int>> xl(n);
  rep(i,n) {
    int x,l;
    cin>>x>>l;
    xl[i]=make_pair(x,l);
  }
  sort(xl.begin(),xl.end());
  int c = 0;
  int xprev = xl[0].first;
  int lprev = xl[0].second;
  repeat(i,1,n) {
    int x = xl[i].first;
    int l = xl[i].second;
    if(xprev+lprev<=x-l) {
      c++;
      xprev = x;
      lprev = l;
    } else {
      if(x+l<=xprev+lprev) {
	xprev = x;
	lprev = l;
      }
    }
  }
  cout << c + 1 << endl;
  return 0;
}


Measured memory_bytes: 1024
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
ok = [False]*(N+1)
for x in a:
    ok[x] = True
for n in range(2,N+1):
    if ok[n]:
        continue
    dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))


Measured memory_bytes: 17108