akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int N = 222222;
int n, m;
ll a[N], add1[N], sub1[N], sub2[N];

int dis(int a, int b){return (b - a + m) % m;}

int main(){
	read(n), read(m);
	rep(i, 1, n) read(a[i]);
	ll cur = 0, ret = 0;
	rep(i, 2, n){
		int l = a[i-1], r = a[i];
		l++; if (r < l) r += m;
		add1[l]++, sub1[r]++, sub2[r] += r - l;
		ret += l <= m&&m + 1 <= r||l <= 0&&1 <= r;
	}
	rep(i, 2, n) cur += min(dis(a[i-1], a[i]), 1 + dis(1, a[i]));
	ll mi = cur;
	ret += add1[1] + add1[m+1] - sub1[1] - sub1[m+1];
	cur += sub2[1] + sub2[m+1];
	rep(i, 2, m){
		cur -= ret, mi = min(mi, cur);
		ret += add1[i] + add1[m+i] - sub1[i] - sub1[m+i];
		cur += sub2[i] + sub2[m+i];
	}
	printf("%lld\n", mi);
	return 0;
}

Measured memory_bytes: 5248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

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

                String[] ss=br.readLine().split(" ");
               int n=Integer.parseInt(ss[0]);
               int m=Integer.parseInt(ss[1]);
               System.out.println((n*(n-1))/2 + m*(m-1)/2);



        }catch(Exception e){
            System.out.println("kkkk");
        }
    }
    static class pair{
        int a,b;
        public pair(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
}

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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int N;
int A[304][304], d[304][304];
int s;

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N;
  rep(i, N) {
    rep(j, N) {
      cin>>A[i][j];
      d[i][j] = A[i][j];
    }
  }
  
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if(A[i][j]>A[i][k]+A[k][j]) {
          cout<<-1<<endl;
          return 0;
        }
        
        if(A[i][j]==A[i][k]+A[k][j]) {
          if(i!=k&&j!=k)d[i][j] = 0;
        }
      }
    }
  }
  
  rep(i, N) {
    for_(j, i, N) {
      s += d[i][j];
    }
  }
  
  cout<<s<<endl;
  
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}

int main()
{
   ll X,Y,n,m,k;
   cin>>X>>Y>>n>>m>>k;
   ll A[n],B[m],C[k];
   ll i;
   for(i=0;i<n;i++)
   {
       cin>>A[i];
   }
   for(i=0;i<m;i++)
   {
       cin>>B[i];
   }
   for(i=0;i<k;i++)
   {
       cin>>C[i];
   }
   sort(A,A+n,greater<ll>());
   sort(B,B+m,greater<ll>());
   sort(C,C+k,greater<ll>());
   ll S1=0,S2=0;
   for(i=0;i<X;i++)
   {
       S1+=A[i];
   }
   for(i=0;i<Y;i++)
   {
       S2+=B[i];
   }
   int posc=0,posa=X-1,posb=Y-1;
   ll S=S1+S2;
   ll ans=S;
   while(posc<k)
   {
       if(posa<0&&posb<0)
       {
           break;
       }
       else
       {
           if(posa>=0&&posb<0)
           {
               if(C[posc]>A[posa])
               {
                   S-=A[posa];
                   S+=C[posc];
                   posc++;
                   posa--;
               }
               else
               {
                   posc++;
               }
           }
           else if(posb>=0&&posa<0)
           {
               if(C[posc]>B[posb])
               {
                   S-=B[posb];
                   S+=C[posc];
                   posc++;
                   posb--;
               }
               else
               {
                   posc++;
               }
           }
           else
           {
               ll p,q;
               if(C[posc]>A[posa]&&C[posc]>B[posb])
               {
                   p=C[posc]-A[posa];
                   q=C[posc]-B[posb];
                   if(p>=q)
                   {
                       S-=A[posa];
                       S+=C[posc];
                       posa--;
                       posc++;
                   }
                   else
                   {
                       S-=B[posb];
                       S+=C[posc];
                       posc++;
                       posb--;
                   }
               }
               else
               {
                   if(C[posc]>A[posa])
                   {
                       S-=A[posa];
                       S+=C[posc];
                       posa--;
                       posc++;
                   }
                   else if(C[posc]>B[posb])
                   {
                       S-=B[posb];
                       S+=C[posc];
                       posb--;
                       posc++;


                   }
                   else
                   {
                       posc++;
                   }
               }

           }
       }
   }
   cout<<S;


}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());

		int cost_0 = 0;
		for(int i = 0; i < m; i--) {
			if(Integer.parseInt(sc.next()) < x) {
				cost_0++;
			}else {
				break;
			}
		}
		
		int cost_x = m - cost_0;
		if(cost_0 <= cost_x) {
			System.out.println(cost_0);
		}else {
			System.out.println(cost_x);
		}

	}

}


Measured memory_bytes: 22868
import Control.Monad

main = do
  s <- getLine
  let [x,y] = map (read ::String->Int) $ words s in
    if x /= 0 && y /= 0 then do
      forM_ [1..x] $ \ i -> do
        putStr $ replicate y '#' ++ "\n"
      putStr "\n"
      main
    else
      return ()

Measured memory_bytes: 4032
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
#define endl '\n'
#define all(v) v.begin(), v.end()

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(a, k);
    k -= a;
    if (k > 0) {
        k -= b;
        if (k > 0) {
            ans -= (k);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

struct Query{

	ll q,x,s,t;
};

ll N,Q,minimum,maximum;
ll A[SIZE];
Query query[SIZE];


int main(){

	scanf("%lld %lld %lld %lld",&N,&Q,&minimum,&maximum);

	for(int i = 0; i < N; i++){

		scanf("%lld",&A[i]);
	}

	sort(A,A+N);

	for(int i = 0; i < Q; i++){

		scanf("%lld %lld %lld %lld",&query[i].q,&query[i].x,&query[i].s,&query[i].t);
	}

	int left = N;
	int L = 0,R = N-1,mid = (L+R)/2;

	while(L <=R){

		ll tmp = A[mid];

		for(int i = 0; i < Q; i++){

			if(query[i].q == 1){ //AddMul

				if(tmp < query[i].x)continue;

				tmp += query[i].s;
				tmp *= query[i].t;

			}else{ //SubDiv

				if(tmp > query[i].x)continue;

				tmp -= query[i].s;
				tmp /= query[i].t;
			}
		}

		if(tmp >= minimum){

			left = mid;
			R = mid-1;

		}else{

			L = mid+1;
		}
		mid = (L+R)/2;
	}

	int right = -1;
	L = 0,R = N-1,mid = (L+R)/2;

	while(L <= R){

		ll tmp = A[mid];

		for(int i = 0; i < Q; i++){

			if(query[i].q == 1){ //AddMul

				if(tmp < query[i].x)continue;

				tmp += query[i].s;
				tmp *= query[i].t;

			}else{ //SubDiv

				if(tmp > query[i].x)continue;

				tmp -= query[i].s;
				tmp /= query[i].t;
			}
		}

		if(tmp <= maximum){

			right = mid;
			L = mid+1;

		}else{

			R = mid-1;
		}
		mid = (L+R)/2;
	}

	printf("%d\n",max(0,right-left+1));

	return 0;
}



Measured memory_bytes: 10900
import java.util.*;

public class Main {
    
    public static void main(String arg[]) {
        try{
            Scanner scan = new Scanner(System.in);
            int S = scan.nextInt();
            if(0<=S && S<86400){
            int s = S%60;
            int m = (S/60)%60;
            int h = S/3600;
            System.out.println(h+":"+m+":"+s);
            }else{
                System.out.println("1??????100?????§???????????§???");
            }
            
        }catch(InputMismatchException ex){
            System.out.println("1??????100?????§????????¶??°?????\?????????????????????");
        }
    }
}

Measured memory_bytes: 26368
n,d=map(int,input().split())
a=[]
ans=0

for i in range(n):
  b=list(map(int,input().split()))
  a.append(b)
for i in range(n-1):
  for j in range(i+1,n):
    cnt=1
    dist=0
    for k in range(d):
      dist+=(a[i][k]-a[j][k])**2
    while cnt**2<=dist:
      if cnt**2==dist:
        ans+=1
      cnt+=1
print(ans)

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;

    int res = 0;
    for (int i = 0; i < n - 1; ++i) {
        res += s[i] == s[i + 1];
    }
    cout << min(res + 2 * k, n - 1) << '\n';
    return 0;
}


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

int main()
{
	int N,sum = 0;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++){
		cin >> L[i];
	}
	sort(L.begin(), L.end(), greater<int>());
	
	for (int i = 1; i < N; i++) {
		sum += L[i];
	}

	if (L[0] < sum) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

static const ll MAX=2000000000;

int main(){
    ll L,R;
    cin >> L >> R;
    if(R<2019){
        ll ans=MAX;
        for(ll i=L;i<R;i++){
            for(int j=i+1;j<=R;j++){
                ans=min(ans,i*j%2019);
            }
        }
        cout << ans << endl;
    }else if(L<=2019&&R>=2019){
        cout << 0 << endl;
    }else if(L>2019){
        for(ll i=4038;i<=MAX;i+=2019){
            if(L<=i&&R>=i){
                cout << 0 << endl;
                return 0;
            }
        }
        ll ans=MAX;
        for(ll i=L;i<R;i++){
            for(int j=i+1;j<=R;j++){
                ans=min(ans,i*j%2019);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B, K = map(int, readline().split())
    t = max(A - K, 0)
    a = min(A + B - K, B)
    a = max(a, 0)
    print(t, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BTag {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        lint A, B, V, W, T;
        in>>A>>V>>B>>W>>T;
        if(V<=W) out<<"NO\n";
        else{
            if(abs(A-B)<=T*(V-W)) out<<"YES\n";
            else out<<"NO\n";
        }
    }
};


int main() {
	BTag solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(u == s){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  int ans =0;
  for(int i=1;i<=n;i++){
    if(1<=i && i<=9){
      ans++;
    }
    else if(100<=i && i<=999){
      ans++;
    }
    else if(10000<=i && i<=99999){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;



int main(){
    int a,b;
    cin >> a >> b;
    int sa = b - a;
    int ans = 0;
    for(int i = 0; i < sa; i++){
        ans += i;
    }
    cout << ans - a << endl;
}


Measured memory_bytes: 256
import math

A, B, H, M = list(map(int, input().split()))

kakudo = 60*H - (11*M) # / 60*12  * 2pi

ans2 = A**2 + (B**2) - 2*A*B*math.cos(math.pi*kakudo/360)
print("{:.15f}".format(math.sqrt(ans2)))

Measured memory_bytes: 9492
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;

template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define forn(i,x,y) for(int i=(x);i<(int)(y);i++)
#define rep(i,y) for(int i=0;i<(int)(y);i++)
#define repb(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)

template<class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << " ";
    os << *it;
  }
  return os;
}

int n,z,w;


int main() {
  cin>>n>>z>>w;
  int mxscore = 0;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  int x,y;

  if (n>1) {
    x = vec[n-1];
    y = vec[n-2];
    chmax(mxscore, abs(x-y));
  }

  x = vec[n-1];
  y = w;
  chmax(mxscore, abs(x-y));

  cout << mxscore << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string t[7]={"SUN","SAT","FRI","THU","WED","TUE","MON"};
  string s;
  R s;
  if(s=="SUN") {
	pr(7);
    return;
  }
  rep(i,7) {
    if(t[i]==s) {
      pr(i);
      return;
    }
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

bool ch[1000];

signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int res = 0;
	while((res = (res+a)%b) != c) {
		if (ch[res]) {
			cout << "NO" << endl;
			return 0;
		}
		ch[res] = true;
	}
	cout << "YES" << endl;
}



Measured memory_bytes: 256
#include<stdio.h>


int main(void){
    int n,i,u[50],j,f,x;
    double v[50];
    double val;
    scanf("%d",&n);
    for(i = 0; i < n; i++) {
        scanf("%d",&u[i]);
    }
    for(i = 0; i < n; i ++) {
        for(j = i+1; j < n; j++) {
            if(u[i] > u[j]) {
                x = u[i];
                u[i] = u[j];
                u[j] = x;
            }
        }
    }
    
    for(i = 0; i < n; i++) {
        v[i] = u[i];
    }

    for(i = 1; i < n; i++) {
        v[i] = (v[i-1] + v[i]) / 2;
    }
    val = v[n-1];
    printf("%lf\n", val);




    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;
#define MAX 10000003
#define INF INTMAX_MAX

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};


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

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

bool cmp(const pll &a, const pll &b)
{
    if (a.F != b.F) {
        return a.F > b.F;
    }
    else
        return a.S < b.S;
}

int main()
{

    fastIO;
    int test = 1, b = 1;
    //cin >> test;
    while (test--)
    {
        int a, b, c, k;
        cin >> a >> b >> c >> k;
        int x = 0;
        while (b <= a) {
            b *= 2;
            x++;
        }
        while (c <= b) {
            c *= 2;
            x++;
        }
        if (x <= k) cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <cstdio>

int main(){
	int a, b, c, d, e, f;
	double x, y;
	while(scanf("%d %d %d %d %d %d\n", &a, &b, &c, &d, &e, &f) != EOF){
		y = (double)(a * f - c * d) / (double)(a * e - b * d);
		x = ((double)c - (double)b * y) / (double)a;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

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

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int s = 0;
    for (int j = i; j > 0; j /= 10) {
      s += j % 10;
    }
    if (s >= a && s <= b) {
      sum += i;
    }
  }
  cout << sum;

  return 0;
}


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

int main() {

  int N;
  cin >> N;
  vector<string> s(N);

  for(int i = 0; i < N; i++) {
      cin >> s[i];
  }
    int ac, wa, tle, re;
    ac = 0;
    wa = 0;
    tle = 0;
    re = 0;

  for(int i = 0; i < N; i++) {
      if(s[i] == "AC") ac++;
      else if(s[i] == "WA") wa++;
      else if(s[i] == "TLE") tle++;
      else if(s[i] == "RE") re++;
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;  


 return 0;
}



Measured memory_bytes: 6340
#include <iostream>
#include <cmath>

using namespace std;

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

    int a[30 + 1] = {};
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int t;
            cin >> t;
            a[t]++;
        }
    }
    int ans = 0;
    for (int i = 0; i <= 30; ++i) {
        if (a[i] == n)
            ++ans;
    }
    cout << ans;
}


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

// #include <atcoder/all>

// #LIB#

using namespace std;
// using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll x;
  cin >> x;
  cout<<!x<<endl;
}


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

#define nax 100009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back

typedef long long ll;

int main(){
	ll n,w[200],val[200],dp[nax],we;
	cin>>n>>we;

	REP(i,n){
		cin>>w[i]>>val[i];
	}

	REP(i,nax) dp[i] = 0;

	REP(i,n){
		for(int j=we;j>=0;j--){
			if(j-w[i]>=0){
				dp[j] = max(dp[j],
					dp[j-w[i]]+val[i]);
			}
		}
	}

	ll m = 0;
	REP(i,we+1){
		m = max(m,dp[i]);
	}

	cout<<m<<endl;

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	cout << (s.length() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I' ? "Yes" : "No") << endl;
	return 0;
}


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

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n,-1);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(i%2){
            b[n/2-i/2-1] = a[i];
        }else{
            b[n/2+i/2] = a[i];
        }
    }
    if(n%2) reverse(b.begin(),b.end());
    rep(i,n) cout << b[i] << ' ';
    cout << endl;
}

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

using namespace std;

#define il inline
#define Rep(i, s, e) for (int i = s; i <= e; ++i)
#define Dep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

typedef long double db;

const db eps = 1e-8;

const int N = 200010;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n, k, nmax;
int len[N];

bool check(db goal) {
    int cnt = 0;
    Rep(i, 1, n) {
    	cnt += ceil(len[i] / goal) - 1;
	}
    return cnt <= k;
}

int main() {
    n = read(), k = read();
    Rep(i, 1, n) len[i] = read(), nmax = max(nmax, len[i]);
    db l = 0, r = nmax;
    while (r - l > eps) {
        db mid = (l + r) / 2;
        if (!check(mid)) l = mid;
        else r = mid;
    }
    /*
    int x = floor(l);
    if (l + eps > 0.5 + x) cout << x + 1;
    else cout << x;
    */
    if (l == int(l)) cout << int(l);
    else cout << int(l) + 1;
    return 0;
}

Measured memory_bytes: 4404
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int g = 0;
        if (a >= 1 && b <= 10000 && c >= 1 && c <= 10000) {
            for (int d = 1; d <= c; d++) {
                int e = c / d;
                int f = c % d;

                if (f == 0 && e <= b && e >= a) {
                    g++;

                }
            }
            System.out.println(g);
        }

    }
}

Measured memory_bytes: 26104
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 1; --i) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  //rep(i, n) cout << r[i] << endl;
  //rep(i, n) cout << l[i] << endl;

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



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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 1e5 + 10;
const int M = (int) 1e6 + 10;
const int K = (int) 500 + 10;
const int mod = (int) 1e9 + 7;

int n;
int a[N];

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; ) {
		int j = i;
		while (j <= n && a[i] == a[j]) 
			j++;
		ans += (j - i) / 2;
		i = j;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i,ma=0,man;
  cin>>n;
  vector<int> a(n),b(n);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    if(ma<a.at(i)){
      ma=a.at(i);
      man=1;
    }
    else if(ma==a.at(i)) man++;
  }
  for(i=0;i<n;i++){
    if(a.at(i)==ma && man==1){
      b=a;
      sort(b.begin(),b.end());
      cout<<b.at(n-2)<<endl;
    }
    else cout<<ma<<endl;
  }
}

Measured memory_bytes: 3200
n,k = input().split(' ')
n = int(n)
k = int(k)
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
diffs = []
for i in range(n-k+1):
    diffs.append(h[i+k-1] - h[i])
print(min(diffs))


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

#Ai=0を含まない...9^N
#Ai=9を含まない...9^N
#Ai=0,Ai=9を含まない...8^N
#全てで10^N通り
#Ai=0,Ai=9の少なくとも一方が存在しない 9^N+9^N-8^N
#答は10^N-9^N-9^N+8^N
MOD=10**9+7
print((pow(10,N,MOD)-2*pow(9,N,MOD)+pow(8,N,MOD))%MOD)


Measured memory_bytes: 9152
n = int(input())
a = list(map(int, input().split()))
a.sort()
try:
    for i, a_i in enumerate(a):
        if n % 2 == 1:
            assert a_i == (i + 1) // 2 * 2
        else:
            assert a_i == i // 2 * 2 + 1
    answer = pow(2, n // 2, 10 ** 9 + 7)
except AssertionError:
    answer = 0
print(answer)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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 dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll l,r,d;
  cin>>l>>r>>d;
  ll ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0) ans++;
  }
  COUT(ans);
}
  

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace V0026{
    public class Program{
        public static void Main(string[] args){
            var dx = new[]{
                new[]{0, 1, 0, -1, 0},
                new[]{0, 1, 0, -1, 0, 1, 1, -1, -1},
                new[]{0, 1, 0, -1, 0, 1, 1, -1, -1, 2, -2, 0, 0}
            };
            var dy = new[]{
                new[]{0, 0, 1, 0, -1},
                new[]{0, 0, 1, 0, -1, 1, -1, 1, -1},
                new[]{0, 0, 1, 0, -1, 1, -1, 1, -1, 0, 0, 2, -2}
            };
            Func<int, int, bool> isInside = (x, y) => 0 <= x && x < 10 && 0 <= y && y < 10;

            var paper = new int[10, 10].ToJaggedArray();
            while(Console.In.Peek() != -1){
                var line = Array.ConvertAll(Console.ReadLine().Split(','), int.Parse);
                var x = line[0];
                var y = line[1];
                var s = line[2] - 1;

                for(var i = 0; i < dx[s].Length; i++){
                    var tx = x + dx[s][i];
                    var ty = y + dy[s][i];
                    if(isInside(tx, ty)){
                        paper[ty][tx]++;
                    }
                }    
            }

            Console.WriteLine(paper.SelectMany(x => x).Count(x => x == 0));
            Console.WriteLine(paper.SelectMany(x => x).Max());
        }
    }

    public static class ExMethod{
        public static T[][] ToJaggedArray<T>(this T[,] src){
            var x = src.GetLength(1);
            var y = src.GetLength(0);
            var ret = new T[y][];

            for(var i = 0; i < y; i++){
                ret[i] = new T[x];
                for(var j = 0; j < x; j++){
                    ret[i][j] = src[i, j];
                }
            }

            return ret;
        } 
    }
}

Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=(int)1e5+7;

int n,l[N],r[N];
int id1[N],id2[N],cnt1,cnt2;
ll ans;
bool used[N];

il bool cmp1(const int &x,const int &y){
	return l[x]>l[y]||l[x]==l[y]&&r[x]>r[y];
}

il bool cmp2(const int &x,const int &y){
	return r[x]<r[y]||r[x]==r[y]&&l[x]<l[y];
}

il void go(int d,int p,ll cur){
//	cerr<<p<<" ";
	while(cnt1<=n&&used[id1[cnt1]]) ++cnt1;
	while(cnt2<=n&&used[id2[cnt2]]) ++cnt2;
	if(cnt1>n&&cnt2>n){
		getmax(ans,cur+abs(p));
		return;
	}
	int nid;
	if(d==0){
		used[id1[cnt1]]=true;
		nid=id1[cnt1];
	}else if(d==1){
		used[id2[cnt2]]=true;
		nid=id2[cnt2];
	}else assert(false);
	if(p<l[nid]) go(d^1,l[nid],cur+l[nid]-p);
	else if(p>r[nid]) go(d^1,r[nid],cur+p-r[nid]);
	else go(d^1,p,cur);
}

int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d%d",l+i,r+i);
		id1[i]=id2[i]=i;
	}
	sort(id1+1,id1+n+1,cmp1);
	sort(id2+1,id2+n+1,cmp2);
	ans=0;
	cnt1=cnt2=1;
	go(1,0,0);
//	cerr<<endl;
	cnt1=cnt2=1;
	memset(used+1,0,sizeof(bool)*n);
	go(0,0,0);
//	cerr<<endl;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 998244353
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 1000005

void solve()
{
	lli n;
	cin>>n;

	lli a[2*n];
	loopl(i,0,2*n) cin>>a[i];

	sort(a,a+2*n);

	lli cnt=0;
	for(lli i=0;i<2*n;i+=2) cnt+=a[i];

		cout<<cnt<<endl;
}
 
int main()
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////  
 	
	lli t;
	t=1;
 
	while(t--)
		solve();
 
}

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

using namespace std;
typedef long long ll;
const int INF = numeric_limits<int>::max() / 2;

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

  ll sum=0,n;cin>>n;
  int t[n+1];
  for(int i=0;i<n;i++){
      cin>>t[i+1];
      sum+=t[i+1];
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
      int p,x;cin>>p>>x;
      cout<<sum-t[p]+x<<endl;
  }
}


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

using namespace std;

using P = pair<int, int>;

int h, w, r, c;

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

    while (cin >> h >> w >> r >> c, h || w || r || c)
    {
        r--;
        c--;
        vector<vector<int>> hor(h + 1, vector<int>(w));
        vector<vector<int>> ver(h, vector<int>(w + 1));
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
                cin >> hor[i][j];
            for (int j = 0; j < w + 1; j++)
                cin >> ver[i][j];
        }
        for (int j = 0; j < w; j++)
            cin >> hor[h][j];
        // (i, j) の上:hor[i][j], 左:ver[i][j], 下:hor[i+1][j], 右:ver[i][j+1]
        vector<vector<bool>> cls(h, vector<bool>(w, false)), opn(h, vector<bool>(w, false));
        queue<P> que;
        // up, left, down, right
        int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (1 <= i && i < h - 1 && 1 <= j && j < w - 1)
                    continue;
                vector<int> dir = {hor[i][j], ver[i][j], hor[i + 1][j], ver[i][j + 1]};
                for (int k = 0; k < 4; k++)
                {
                    int nx = i + dx[k], ny = j + dy[k];
                    if (nx < 0 || h <= nx || ny < 0 || w <= ny)
                    {
                        if (dir[k])
                            cls[i][j] = true;
                        else
                            opn[i][j] = true;
                    }
                }
                if (cls[i][j] && opn[i][j])
                {
                    que.push(P(i, j));
                }
            }
        }
        while (!que.empty())
        {
            P p = que.front();
            que.pop();
            int x = p.first, y = p.second;
            vector<int> dir = {hor[x][y], ver[x][y], hor[x + 1][y], ver[x][y + 1]};
            for (int i = 0; i < 4; i++)
            {
                int nx = x + dx[i], ny = y + dy[i];
                if (nx < 0 || h <= nx || ny < 0 || w <= ny)
                    continue;
                if (cls[nx][ny] && opn[nx][ny])
                    continue;
                if (dir[i])
                    cls[nx][ny] = true;
                else
                    opn[nx][ny] = true;
                if (cls[nx][ny] && opn[nx][ny])
                {
                    que.push(P(nx, ny));
                }
            }
        }
        bool f = (cls[r][c] && opn[r][c]);
        for (int i = 0; i < 4; i++)
        {
            int nx = r + dx[i], ny = c + dy[i];
            vector<int> dir = {hor[r][c], ver[r][c], hor[r + 1][c], ver[r][c + 1]};
            if (dir[i])
                continue;
            if (nx < 0 || h <= nx || ny < 0 || w <= ny)
                f = true;
            else if (cls[nx][ny] && opn[nx][ny])
                f = true;
        }
        cout << (f ? "Yes" : "No") << endl;
    }
}



Measured memory_bytes: 5012
n = int(input())
line = ""
for i in range(1, n + 1):
    if(i % 3 == 0):
        line += " " + str(i)
        continue
    x = i
    while(x):
        if(x % 10 == 3):
            line += " " + str(i)
            break
        x //= 10
print(line)

Measured memory_bytes: 7624
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;
int main(){
    int n,t;
    cin>>n>>t;
    ll r= 0;
    ll pr = 0;
    int x;
    for(int i=0 ; i< n; i++){
        scanf("%d",&x);
        if(pr > x){
            r -= pr-x;
        }
        r += t;
        pr = x + t;
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n, d[200000], z=0;
vector<int> v[200000];
void f(int x, int y){
    for(int i=0;i<v[x].size();i++){
        int c=v[x][i];
        if(c!=y){
            d[c]=d[x]+1;
            f(c, x);
            if(d[c]>d[z]){
                z=c;
            }
        }
    }
}
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin>>a>>b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    d[0]=0;
    f(0, -1);

    d[z]=0;
    f(z, -1);
    /*
    cout<<d[z]<<endl;
    for(int i=0;i<n;i++){
        cout<<i<<" : "<<d[i]<<endl;
    }
    */
    if(d[z]%3==1){
        cout<<"Second"<<endl;
    }else{
        cout<<"First"<<endl;
    }
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,R,S,P;
  cin>>N>>K>>R>>S>>P;
  string T;
  cin>>T;
  int n=N/K+1;
  vector<vector<char>>pred(n,vector<char>(K,'o'));
  for(int i=0;i<n;i++){
    for(int j=0;j<K;j++){
		if(i*K+j>=N)break;
        else pred[i][j]=T[i*K+j];
    }
  }
  int s=0;
  for(int j=0;j<K;j++){
    int c=0;
    for(int i=0;i<n;i++){
      if(i==0)c=0;
      else if(pred[i][j]!=pred[i-1][j]) c=0;
      else c++;
      
      if(c%2==1)s+=0;
      else{
        if(pred[i][j]=='r')s+=P;
        else if(pred[i][j]=='s')s+=R;
        else if(pred[i][j]=='p')s+=S;
        else s+=0;
      }
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 5760
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
h = list(myinput())
h = [0] + h
m = 0
ans = 0
for i in range(n):
    a = h[i]
    b = h[i+1]
    if a<=b:
        if (i+1)==n:
            ans += b - m
        else:
            pass
    else:
        ans += a - m
        m = b
print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector<bool> have(n);
    rep(i,k){
        int d; cin>>d;
        rep(j,d){
            int a; cin>>a; a--;
            have[a]=true;
        }
    }
    int ans=0;
    rep(i,n)if(!have[i]){
        ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
bool dp[20][2001];


int main(){
	int n,a,qn,q;
	vector<int> A;
	cin >> n;
	REP(i,n){cin>>a;dp[i][a]=dp[i][0]=true;A.push_back(a);}
	cin >> qn;

	for(int j=1;j<n;j++){
		REP(k,2001){
				dp[j][k] |= dp[j-1][k]; 
				if(A[j] < k) dp[j][k] |= dp[j-1][k-A[j]];
		}
	}
	REP(i,qn){
		cin >> q;cout<< ((dp[n-1][q])?"yes":"no") << endl;
	}
}

Measured memory_bytes: 3068
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int E;
int A[102]={};
int main() {
	for(int i=0;i<12;i++){
		cin>>E;
		A[E]+=1;
	}

	int R=0;
	for(int i=1;i<101;i++){
		if(A[i]==4)R+=1;
		if(A[i]==8)R+=2;
		if(A[i]==12)R=3;
	}

	if(R==3)cout<<"yes"<<endl;

	else cout<<"no"<<endl;

	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,ans;
bool dp[10][10][10][3];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
		char c;
		scanf(" %c",&c);
		int x=c-'0';
		for(int j=0;j<10;j++)for(int k=0;k<10;k++)if(dp[j][k][0][1])dp[j][k][x][2]=true;
		for(int j=0;j<10;j++)if(dp[j][0][0][0])dp[j][x][0][1]=true;
		dp[x][0][0][0]=true;
	}
	for(int i=0;i<10;i++)for(int j=0;j<10;j++)for(int k=0;k<10;k++)if(dp[i][j][k][2])ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int ai,n,i,min,max;

long sum;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&ai);

if(i==0){

min=ai;

max=ai;

sum=ai;

}

else{

sum=sum+ai;

if(min>ai){

min=ai;

}

if(max<ai){

max=ai;

}

}

}

printf("%d %d %ld\n",min,max,sum);

return 0;

}  

Measured memory_bytes: 600
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void myout(Object text){System.out.println(text);}
	public static String getStr(){return sc.next();}
	public static int getInt(){return sc.nextInt();}
	public static Long getLong(){return sc.nextLong();}
	public static boolean isNext(){return sc.hasNext();}
	public static void main(String[] args){
		//String tmp = getStr();
		//int tmp = getInt();
		//Long tmp = getLong();
      Long output = new Long(0);
      Long N = getLong();
      Long M = getLong();
      if(N >= M / 2){
        output = M / 2;
      }else{
        output = N + ((M - (N * 2)) / 4);
      }
      myout(output);
	}
}


Measured memory_bytes: 23892