akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  c++;
  cout<<c<<endl;
}

Measured memory_bytes: 256
//https://www.codechef.com/LTIME59A/problems/GCDDIV
#include <bits/stdc++.h>
#define INF 9999999999
using namespace std;

int main() {
    long long n, h;
    cin >> h >> n;
    vector<pair<long long, long long> > spell(n + 1);
    for(long long i = 1; i <= n; i++) {
        cin >> spell[i].first >> spell[i].second;
    }
    sort(spell.begin() + 1, spell.end());
    long long dp[h + spell[n].first + 1];
    long long siz = h + spell[n].first + 1;
    for(long long i = 1; i < siz; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for(long long i = 1; i < siz; i++) {
        for(long long j = 1; j <= n; j++) {
            if(spell[j].first > i)
                break;
            dp[i] = min(dp[i], spell[j].second + dp[i - spell[j].first]);
        }
    }
    long long ans = INF;
    for(long long i = h; i < siz; i++) {
        ans = min(dp[i], ans);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int submit[31]={0};
    int submiter;
    for(int i=0;i<28;i++){
        cin >> submiter;
        submit[submiter] = 1;
    }
    for(int i=1;i<31;i++){
        if(submit[i] == 0){
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 1160
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long A = scanner.nextLong();
        long B = scanner.nextLong();

        if (A <= 0) {
            System.out.println(0);
            return;
        }

        // 0 < A

        if (B <= 0) {
            System.out.println(N);
            return;
        }

        // 0 < A
        // 0 < B

        if (A >= N) {
            System.out.println(N);
            return;
        }

        // 0 < A < N
        // 0 < B

        if (B >= N) {
            System.out.println(A);
            return;
        }

        // 0 < A < N
        // 0 < B < N

        if (A + B >= N) {
            // 0 < A < N
            // 0 < B < N
            // 0 < N <= A + B
            System.out.println(A);
            return;
        }

        // 0 < A < N
        // 0 < B < N
        // 0 < A + B < N

        long sho = N / (A + B);
        long jouyo = N % (A + B);
        System.out.println(sho * A + Math.min(jouyo, A));
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n = s.size();
	string dream = "maerd", dreamer = "remaerd", erase = "esare", eraser = "resare";
	reverse(s.begin(),s.end());
	bool ok = true;
	int k = 0;
	while(true){
		if(k == n) break;
		if(k + 5 <= n && s.substr(k,5) == dream || s.substr(k,5) == erase){
			k += 5;
			continue;
		}
		if(k + 6 <= n && s.substr(k,6) == eraser){
			k += 6;
			continue;
		}
		if(k + 7 <= n && s.substr(k,7) == dreamer){
			k += 7;
			continue;
		}
		ok = false;
		break;
	}
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

typedef long long ll;

ll H, W, K;
ll SX, SY, TX, TY;
vector<vector<bool>> L;
queue<pair<ll, ll>> Q;
vector<vector<ll>> D;
const ll INF = 1ll << 60;
const ll DX[] = {0, 1, 0, -1};
const ll DY[] = {1, 0, -1, 0};

int main() {
  cin >> H >> W >> K;
  cin >> SX >> SY >> TX >> TY;
  L.resize(H + 2);
  for (auto &Lx : L) Lx.resize(W + 2, true);
  for (ll x = 1; x <= H; ++x) {
    for (ll y = 1; y <= W; ++y) {
      char c;
      cin >> c;
      if (c == '.') L[x][y] = false;
    }
  }
  D.resize(H + 2);
  for (auto &Dx : D) Dx.resize(W + 2, INF);
  Q.push({SX, SY});
  D[SX][SY] = 0;
  while (!Q.empty()) {
    ll x, y;
    tie(x, y) = Q.front();
    Q.pop();
    ll d = D[x][y];
    for (ll i = 0; i < 4; ++i) {
      ll dx = DX[i], dy = DY[i];
      for (ll j = 1; j <= K; ++j) {
        ll x2 = x + j * dx;
        ll y2 = y + j * dy;
        if (L[x2][y2]) break;
        if (D[x2][y2] <= d) break;
        if (D[x2][y2] == d + 1) continue;
        Q.push({x2, y2});
        D[x2][y2] = d + 1;
      }
    }
  }
  ll res = D[TX][TY];
  cout << (res == INF ? -1 : res) << endl;
  return 0;
}


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

int main(){
  string input;
  cin >> input;
  
  int count_one = 0;
  if( input.at(0) == '1' )	count_one++;
  if( input.at(1) == '1' )	count_one++;
  if( input.at(2) == '1' )	count_one++;
  cout << count_one << endl;
}

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

int main() {
    vector<int> len(3);
    cin >> len.at(0) >> len.at(1) >> len.at(2);
    sort(len.begin(), len.end());
    if (len.at(0) == 5 && len.at(1) == 5 && len.at(2) == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}   

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n;cin>>n;
    n=n%10;
    if(n==3)cout<<"bon\n";
    else if(n==0||n==1||n==6||n==8)cout<<"pon\n";
    else cout<<"hon\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b)
{
	return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int> &vec)
{
	for (auto &e : vec)
	{
		cout << e << " ";
	}
	cout << endl;
}

bool is_prime(ll n)
{
	switch (n)
	{
	case 0: // fall-through
	case 1:
		return false;
	case 2: // fall-through
	case 3:
		return true;
	} // n > 3 が保証された

	if (n % 2 == 0)
		return false;
	if (n % 3 == 0)
		return false;
	// 2と3の倍数でないので6の倍数ではないことが保証された

	if (n % 6 != 1 && n % 6 != 5)
		return false;
	// 6の倍数前後の数(素数かもしれない数)であることが保証された

	// 6の倍数前後の数を使って試し割りをする
	for (unsigned i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0)
			return false; // 6n-1
		if (n % (i + 2) == 0)
			return false; // 6n+1
	}

	return true;
}

int main()
{
	ll x;
	cin >> x;

	for (ll i = x; i < 1000000; i++)
	{
		if (is_prime(i))
		{
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dist[305][305],edit[305][305];
int main(){
	int N; scanf("%d", &N);
	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= N; j++){
			scanf("%lld", &dist[i][j]);
			edit[i][j] = dist[i][j];
		}
	}
	for (int k = 1; k <= N; k++){
		for (int i = 1; i <= N; i++){
			for (int j = 1; j <= N; j++){
				if (dist[i][j] > dist[i][k] + dist[k][j])
					return !printf("-1");
				if (k!=i && k!=j && dist[i][j] == dist[i][k] + dist[k][j])
					edit[i][j] = 0;
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= N; i++)
		for (int j = i + 1; j <= N; j++)
			ans += edit[i][j];
	printf("%lld", ans);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
 using namespace std;
 
 int main(){
   int a,b,c;
   cin >> a >> b >> c;
   int temp = a;
   a = b;
   b = temp;
   temp = a;
   a = c;
   c = temp;
   cout << a << " " << b << " " << c << endl;
   return 0;
 }
                    

Measured memory_bytes: 256
N = int(input())
posX, posY, h = [], [], []

for i in range(N):
    tmp = list(map(int, input().split()))
    posX.append(tmp[0])
    posY.append(tmp[1])
    h.append(tmp[2])

h_start = max(h)

for x in range(101):
    for y in range(101):
        for k in range(h_start, h_start + 201):
            flag = True
            for i in range(N):
                tmp_h = max(k - abs(posX[i] - x) - abs(posY[i] - y), 0)
                #print(x, y, k, tmp_h, h[i])
                if tmp_h != h[i]:
                    flag = False
                    break
            if flag == True:
                print(x, y, k)
                exit
        

Measured memory_bytes: 54620
let () = Scanf.scanf " %d %d %d" @@ fun n m c ->
  let bs = List.init m @@ fun _ -> Scanf.scanf " %d" Fun.id in
  let ass = List.init n @@ fun _ ->
    List.init m @@ fun _ -> Scanf.scanf " %d" Fun.id in
  let ans = List.length @@
    List.filter (( < ) 0) @@
    List.map (List.fold_left2 (fun acc b a -> acc + b * a) c bs) ass in
  Printf.printf "%d\n" ans


Measured memory_bytes: 3968
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>
 
#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
 
using ll = long long;
 
typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;
 
typedef struct S{
  int a;
  int b;
} Object;
 
int main(){
  int N;
  cin >> N;
  
  string ans = "No";
  string str = to_string(N);
  for(int i=0;i<str.size();i++){
    if(str[i] == '7'){
      ans = "Yes";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3668
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let trimmed = input.trim();
    let n = match trimmed.parse::<i32>() {
        Ok(n) if n % 2 == 0 => n,
        Ok(n) => n * 2,
        Err(..) => -1i32
    };
    println!("{}", n);
}


Measured memory_bytes: 4476
#include <algorithm>
#include <climits>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

ll to5(ll a) { return a * a * a * a * a; }

int main() {
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;

    for (int i = -120; i < 120; i++) {
        for (int j = -120; j < 120; j++) {
            if (to5(i) - to5(j) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

#define MAX_V 220
#define INF 1000000000000000000LL

struct edge{long long to,reve;long long cap;};

vector<edge> E[MAX_V];
long long itr[MAX_V],lev[MAX_V];

void ae(long long x,long long y,long long cap){
  E[x].push_back((edge){y,(int)E[y].size(),cap});
  E[y].push_back((edge){x,(int)E[x].size()-1,0});
}

void bfs(long long cur){
  memset(lev,-1,sizeof(lev));
  queue<long long> q;
  lev[cur]=0;
  q.push(cur);
  while(q.size()){
    long long v=q.front(); q.pop();
    for(long long i = 0; i < E[v].size(); i++){
      edge &e = E[v][i];
      if(e.cap>0 && lev[e.to]<0){
        lev[e.to]=lev[v]+1, q.push(e.to);
      }
    }
  }
}

long long dfs(long long from,long long to,long long cf){
  if(from==to) return cf;
  for(long long &i = itr[from]; i < E[from].size(); i++){
    edge &e = E[from][i];
    if(e.cap>0 && lev[from]<lev[e.to]){
      long long f=dfs(e.to,to,min(cf,e.cap));
      if(f>0){
        e.cap-=f;
        E[e.to][e.reve].cap += f;
        return f;
      }
    }
  }
  return 0;
}

long long maxFlowDinic(long long from, long long to) {
  long long fl=0,tf;
  while(1) {
    bfs(from);
    if(lev[to]<0)return fl;
    memset(itr,0,sizeof(itr));
    while((tf=dfs(from,to,numeric_limits<int>::max()))>0)fl+=tf;
  }
}

int main() {
  ll h,w;
  cin>>h>>w;
  vector<string> vs;
  rep(i,0,h){
    string s;
    cin>>s;
    vs.pb(s);
  }
  ll sy,sx;
  ll gy,gx;
  rep(y,0,h){
    rep(x,0,w){
      if(vs[y][x]=='o'){
        ae(y,h+x,1);
        ae(h+x,y,1);
      }
      if(vs[y][x]=='S'){
        sy = y;
        sx = x;
      }
      if(vs[y][x]=='T'){
        gy = y;
        gx = x;
      }
    }
  }
  if(sy==gy||sx==gx){
    cout << -1 << endl;
    return 0;
  }
  ll start = h+w+1;
  ll goal = h+w+2;
  rep(i,0,h){
    ae(start,sy,1000);
    ae(start,h+sx,1000);
    ae(gy,goal,1000);
    ae(h+gx,goal,1000);
  }
  cout << maxFlowDinic(start,goal) << endl;
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int ask(ll p)
{
	cout << "? " << p << endl;
	cout.flush(); string s; cin >> s;
	if (s[0] == 'Y') return 1; else return 0;
}
void put(ll p)
{
	cout << "! " << p << endl;
	cout.flush(); exit(0);
}
int main()
{	
	if(ask(1000000000))
	{
		for (ll i=1;;i*=10)
			if(ask(i*2)) put(i);
	}
	else for(ll i=100000000;i>=1;i/=10)
		if(ask(i))
		{
			ll l=i+1,r=i*10-1;
			while(l<r)
			{
				ll md=(l+r)/2;
				if(ask(md*10+9)) r=md;
				else l=md+1;
			}
			put(l);
		}
}


Measured memory_bytes: 596
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N,ans=0;
    cin >> N ;
    vector<long long>a(N);

    rep(i,N){
        cin >> a[i];
    }
    ans=a[0];
    rep(i,N){
        ans=lcm(a[i],ans);
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<P> d;
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        d.push_back(P(a, b));
    }
    sort(d.begin(), d.end());
    ll ans = 0;
    ll r = 0;
    ll l = 1001001001;
    rep(i, m)
    {
        r = max(r, d[i].first);
        l = min(l, d[i].second);
        if (l - r < 1)
        {
            ans++;
            r = d[i].first;
            l = d[i].second;
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, A, B; cin >> N >> A >> B;
    int k = N / (A + B), r = N % (A + B);

    int a = A * k, b = B * k;
    a += min(r, A);
    b += max(0LL, r - A);

    Out(a);

    return 0;
}


Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=2e5+100;
ll arr[N],L[N],R[N];

int main(){	
	ll n,k,q;cin>>n>>k>>q;	
	For(i,0,q){
		int val;cin>>val;
		val--;
		arr[val]++;
	}
	L[0]=arr[0];
	For(i,0,n)L[i]=L[i-1]+arr[i];
	R[n-1]=arr[n-1];
	roF(i,n-2,0)R[i]=R[i+1]+arr[i];
	For(i,0,n){
		ll val=0;
		if(i+1<n)val+=R[i+1];
		if(i-1>=0)val+=L[i-1];
		if(k-val<=0)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}


	return 0;
}


Measured memory_bytes: 5952
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 

int n;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	printf("%d\n",(1000-n%1000)%1000);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    map<int,ll> p;
    int n;
    ll k;
    cin>>n>>k;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        p[a]+=b;
    }
    for(auto s:p){
        
        if(k<=s.second){
            cout<<s.first<<endl;
            break;
        }
        k-=s.second;
    }
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	multiset<int> s1;
	// multiset<int> s2;
	int n, m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		// if(x%2==0)
		s1.insert(x);
		// else
		// 	s2.insert(x);
	}
	// while(m>0)
	// {
	// 	m--;
	// 	auto it1=s1.end();
	// 	auto it2=s2.end();
	// 	if(s1.size()==0)
	// 	{
	// 		it2--;
	// 		s1.insert(((*it2)+1)/2);
	// 		s2.erase(it2);
	// 		continue;
	// 	}
	// 	else if(s2.size()==0)
	// 	{
	// 		it1--;
	// 		int v=*it1;
	// 		s1.erase(it1);
	// 		v/=2;
	// 		if(v%2==0)
	// 			s1.insert(v);
	// 		else
	// 			s2.insert(v);
	// 		continue;
	// 	}
	// 	it1--;
	// 	it2--;
	// 	int v1=*it1;
	// 	int v2=*it2;
	// 	cout<<v1<<' '<<v2<<endl;
	// 	if(v1==0 && v2==0)
	// 		break;
	// 	if(v2==v1+1 || v2==v1)
	// 	{
	// 		v1/=2;
	// 		s1.erase(it1);
	// 		if(v1%2==0)
	// 			s1.insert(v1);
	// 		else
	// 			s2.insert(v1);
	// 	}
	// 	else
	// 	{
	// 		if(v2>v1)
	// 		{
	// 			v2=(v2+1)/2;
	// 			s2.erase(it2);
	// 			s1.insert(v2);
	// 		}
	// 		else
	// 		{
	// 			v1/=2;
	// 			s1.erase(it1);
	// 			if(v1%2==0)
	// 				s1.insert(v1);
	// 			else
	// 				s2.insert(v1);
	// 		}
	// 	}
	// 	// m--;
	// }
	while(m>0)
	{
		auto it=s1.end();
		it--;
		int v=*it;
		if(v==0)
			break;
		s1.erase(it);
		s1.insert(v/2);
		m--;
	}
	int s=0;
	for(auto i:s1)
	{
		s+=i;
	}
	// for(auto i:s2)
	// {
	// 	s+=i;
	// }
	cout<<s<<endl;
	return 0;

}

Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
	int n;
	int i,j;
	int a,b,c;
	int box;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a>c){
			box=a;
			a=c;
			c=box;
		}
		if(b>c){
			box=b;
			b=c;
			c=box;
		}
		a=a*a;
		b=b*b;
		c=c*c;
		if(a+b==c)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll r;
    cin >> r;

    MSG(fixed << setprecision(15) << 2*r*3.14159265358979323846)
}


Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<list>
 
using namespace std;
 
int  main(int arg,char** argc)
{
  long long int n,a=1,i=0;
  cin>>n;
  while(n>0)
  {
    n/=2;
    i+=a;
    a*=2;
  }
  cout<<i<<"\n";
  
  
    
    return 0;
}

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



int BubSort(int x[ ], int n); 

int main(){

  int N,n[200],d,i,w[200],h[200];
  while(1){
    scanf("%d",&N);
    if(N==0){
      break;
    };
    w[0]=0;
    h[0]=0;
    for(i=1;i<N;i++){
      scanf("%d %d",&n[i],&d);
      if(d==0){
	w[i]=w[n[i]]-1;
	h[i]=h[n[i]];
      }
      else if(d == 1){
	 w[i]=w[n[i]];
	 h[i]=h[n[i]]-1;
      }
      else if(d == 2){
	 w[i]=w[n[i]]+1;
	 h[i]=h[n[i]];
      }
      else if(d == 3){
	 w[i]=w[n[i]];
	 h[i]=h[n[i]]+1;
      }
    }
    for(i=0;i<N;i++){
      BubSort(w,N);
      BubSort(h,N);
    }
    printf("%d %d\n",w[N-1]-w[0]+1,h[N-1]-h[0]+1);
  }
  return 0;
}

int BubSort(int x[ ], int n)
{
  int i, j, temp;
  
  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (x[j - 1] > x[j]) {  /* テ・ツ可催」ツ?ョティツヲツ?ァツエツ?」ツ?ョテヲツ鳴ケテ」ツ?古・ツ、ツァテ」ツ?催」ツ?凝」ツ?」テ」ツ?淌」ツつ?*/
	temp = x[j];        /* テ、ツコツ、テヲツ渉崚」ツ?凖」ツつ?*/
	x[j] = x[j - 1];
	x[j - 1]= temp;
      }
    }	
    
    
  }
  return 0;
}
      
    
    
      

Measured memory_bytes: 604
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    h: usize,
    w: usize,
    k: i32,
    field: [chars; h],
  }
  let mut start = (0, 0);
  'outer: for (i, r) in field.iter().enumerate() {
    for (j, &c) in r.iter().enumerate() {
      if c == 'S' {
        start = (i, j);
        break 'outer;
      }
    }
  }
  let mut dist = vec![vec![1 << 30; w]; h];
  dist[start.0][start.1] = 0;
  use std::collections::VecDeque;
  let mut que = VecDeque::new();
  que.push_back(start);
  let dis = [0, 1, 0, -1];
  let djs = [1, 0, -1, 0];
  while let Some((i, j)) = que.pop_front() {
    let d = dist[i][j];
    for (&di, &dj) in dis.iter().zip(djs.iter()) {
      let ni = i as i32 + di;
      let nj = j as i32 + dj;
      if ni < 0 || ni >= h as i32 || nj < 0 || nj >= w as i32 {
        continue;
      }
      let ni = ni as usize;
      let nj = nj as usize;
      if field[ni][nj] == '#' {
        continue;
      }
      if dist[ni][nj] > d + 1 {
        dist[ni][nj] = d + 1;
        que.push_back((ni, nj));
      }
    }
  }
  let mut d_edge = 1 << 30;
  for (i, r) in dist.iter().enumerate() {
    for (j, &d) in r.iter().enumerate() {
      if d <= k {
        d_edge = cmp::min(d_edge, cmp::min(
          cmp::min(i, h - 1 - i),
          cmp::min(j, w - 1 - j)
        ));
      }
    }
  }

  puts!("{}\n", (d_edge as i32 + k - 1) / k + 1);
}


Measured memory_bytes: 10492
#include <stdio.h>

void main(void){
  long N,A[200000],i,s=0,sum=0,x;
  
  scanf("%ld",&N);
  
  for(i=0;i<N;i++){
    scanf("%ld",&A[i]);
    s+=A[i];
  }
  
  for(i=0;i<N-1;i++){
    s -= A[i];
    x = s % 1000000007;
    sum += A[i] * x;
    sum %= 1000000007;
  }
  printf("%ld",sum);
}

Measured memory_bytes: 3252
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc= new Scanner(System.in);
		
		int N= sc.nextInt();
		int[]member= new int[N+1];
		
		
		
		for(int i=0;i<N-1;i++){
			int x= sc.nextInt();
			member[x]++;
		}
		
		sc.close();
		
		for(int i=1;i<N+1;i++)System.out.println(member[i]);
		
	}

}


Measured memory_bytes: 60168
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        var K = sc.next().toLong()
        val A = LongArray(N) { sc.next().toLong() } + longArrayOf(1000000009L)
        val B = LongArray(M) { sc.next().toLong() } + longArrayOf(1000000009L)
        var ans = 0L
        var total = 0L
        var a = 0
        while (total + A[a] <= K) {
            total += A[a]
            a++
            ans++
        }
        var b = 0
        while (total + B[b] <= K) {
            total += B[b]
            b++
            ans++
        }

        var max = ans
        while (a > 0) {
            a--
            ans--
            total -= A[a]
            while (total + B[b] <= K) {
                total += B[b]
                b++
                ans++
            }
            if (ans > max) max = ans
        }

        pw.println(max)
    }
}


Measured memory_bytes: 68080
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
p = max(k,abs(a-b),abs(a-c),abs(a-d),abs(a-e),abs(b-c),abs(b-d),abs(b-e),abs(c-d),abs(c-d),abs(d-e))
if p == k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 1000001

typedef long long int ll;

using namespace std;

int main()
{
    si(a); si(b);
    if(2*b>=a)
        cout<<"0";
    else
        cout<<(a-2*b);
}

Measured memory_bytes: 256
N, M = map(int, input().split())
k = [input().split() for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for n in range(2 ** N):
    is_mismatch = False
    for i in range(M):
        cnt = 0
        for si in k[i][1:]:
            if (n >> (int(si) - 1)) & 1:
                cnt = (cnt + 1) % 2
        if cnt != p[i]:
            is_mismatch = True
            break
    if not is_mismatch:
        ans += 1
    
print(ans)
    

Measured memory_bytes: 40176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long n, a;
    VI v;
    cin >> n;
    unordered_map<long, long> m;
    REP(i,n) {
        cin >> a;
        v.push_back(a);
        m[a] = i % 2;
    }
    sort(v.begin(), v.end());
    long cnt = 0;
    REP(i,n) {
        if (m[v[i]] != i % 2) cnt++;
    }
    cout << cnt / 2 << endl;
}


Measured memory_bytes: 5148
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static long H;
        static long W;
        static String[] map;
        static void Main(string[] args)
        {
            var K = long.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            //var ABC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();


            if (S.Length <= K)
            {
                Console.WriteLine(S);
            }
            else
            {
                Console.WriteLine(S.Substring(0,(int)K)+ "...");
            }


        }
    }

}


Measured memory_bytes: 17656
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <fstream>
#define rep(i,a,b) for (long long i = a; i < b; i++)
using namespace std;
long long n;

// long long bf(long long p, long long pp , long long sum, vector <long long>& fec){
    
//     if(dp[p]!=-1){
//         return dp[p];
//     }
//     if (pp==n-1){
//         //cout << sum  << endl;
//         return sum;
//     } else if(pp>=n){
//         return 1000000000;
//     }
//     //cout << abs(fec[pp]-fec[p]) << "  " << p << "   " << pp << endl;
//     return dp[p]= min(bf(p+1, p, sum + abs(fec[pp]-fec[p]), fec) , bf(p+2, p, sum + abs(fec[pp]-fec[p]), fec));
// }

int main(){
    long long k;
    cin >> n >> k;
    
    //dp.assign(n+k+k,10000000000000);
    
    long long fector[n+2][2];
    long long SUM = 0;
    memset(fector,0, sizeof (fector));
    rep(i,0,n){
        rep(j,0,2){
            cin >> fector[i][j];
            
        }SUM+= fector[i][1];
    }
    // dp[i][total_value] - smallest total weight
    // (total_value = 1000)
    long long dp[n+2][SUM+1];
    //memset(dp,1000000000, sizeof (dp));
    rep(i,0,n+2){
        rep(j,0,SUM+1){
            dp[i][j] = 1000000005;
        }
    }
    dp[0][0] = 0;
    rep(i,0,n){
        rep(v,0,SUM+1){
            //cout << dp[i][v] << "  " << i << "  " << v << endl;
            if(v-fector[i][1]>=0){
                dp[i+1][v] = min(dp[i][v],dp[i][v-fector[i][1]]+fector[i][0]);
            } else{
                dp[i+1][v] = dp[i][v];
            }
            //cout << dp[i+1][v] << "  " << i+1 << "  " << v << endl;
        }
    }
    long long answer = 0;
    rep(i,0,SUM+1){
        //cout << dp[n][i] << "       " ;
        if(dp[n][i]<=k){
            answer = max(answer, i);
        }
        
    }
    cout << answer << "\n";
    //cout << bf(0, 0, 0, fector) << endl;

}

Measured memory_bytes: 79872
gets
a = gets.chomp.split(" ").map(&:to_i)
a.sort!.reverse!

alice =0
bob = 0

i = 0
while(i < a.size) do
  if i % 2 == 0 then
    alice += a[i]
  else
    bob += a[i]
  end
  i += 1
end

puts alice - bob

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




int main() {
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> v(n);
        for(int i=0;i<n;i++) cin>>v[i];
        int prev=v[0];
        long long int sum=0;
        for(int i=1;i<n;i++){
            if(v[i]<prev){
                sum+=abs(v[i]-prev);
            }
            else
                prev=v[i];
        }
        cout<<sum;
    }
}

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

using namespace std;

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

int main() {
  int n;
  while (cin >> n) {
    if (n % 2) cout << (int)(2 * pow(3, n / 2) - 1) << endl;
    else cout << (int)(pow(3, n / 2) - 1) << endl;
  }
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(){
   int n;
   scanf("%d",&n);
   int card[4][13]={{}};

   char str[2];
   int num;

   int i;
   for(i = 0; i < n ; i++){
       scanf("%s%d",str,&num);
       char ch = str[0];
       if(ch == 'S'){
           card[0][num-1] = 1;
       }
       if(ch == 'H'){
           card[1][num-1] = 1;
       }
       if(ch == 'C'){
           card[2][num-1] = 1;
       }
       if(ch == 'D'){
           card[3][num-1] = 1;
       }
   }


   for(i = 0; i < 13; i++){
       if(card[0][i] == 0){
           printf("S %d\n",i+1);
       }
   }

   for(i = 0; i < 13; i++){
       if(card[1][i] == 0){
           printf("H %d\n",i+1);
       }
   }

   for(i = 0; i < 13; i++){
       if(card[2][i] == 0){
           printf("C %d\n",i+1);
       }
   }

   for(i = 0; i < 13; i++){
       if(card[3][i] == 0){
           printf("D %d\n",i+1);
       }
   }

}



Measured memory_bytes: 2036
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int x[100100], y[100100];

vector<int> G[100100];
ll dp[100100][2];

ll calc(int v, bool c, int p) {
    if (dp[v][c] < 0) {
        ll res = 1;
        if (c) {
            for (int i = 0; i < (int)G[v].size(); i++) {
                int u = G[v][i];
                if (u == p) continue;
                res *= calc(u, 0, v);
                res %= mod;
            }
        } else {
            for (int i = 0; i < (int)G[v].size(); i++) {
                int u = G[v][i];
                if (u == p) continue;
                res *= (calc(u, 0, v) + calc(u, 1, v));
                res %= mod;
            }            
        }
        dp[v][c] = res;
    }
    return dp[v][c];
}

ll solve() {
    for (int i = 0; i < n-1; i++) {
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }
    memset(dp, -1, sizeof(dp));
    return (calc(0, 0, -1) + calc(0, 1, -1)) % mod;
}

void input() {
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int c[4][4];
    rep1(i,3)rep1(j,3)cin>>c[i][j];
    int b[4];
    for(int a1=0;a1<=100;a1++){
        b[1]=c[1][1]-a1;
        b[2]=c[1][2]-a1;
        b[3]=c[1][3]-a1;
        if((c[2][1]-b[1])==(c[2][2]-b[2])&&(c[2][1]-b[1])==(c[2][3]-b[3])&&(c[2][3]-b[3])==(c[2][2]-b[2])&&(c[3][1]-b[1])==(c[3][2]-b[2])&&(c[3][1]-b[1])==(c[3][3]-b[3])&&(c[3][3]-b[3])==(c[3][2]-b[2])){co("Yes");return 0;}
    }
    co("No");
}


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

int main() {
    long long N,M;
    cin >> N >> M;
    vector<P>A(N);
    for(long long i = 0; i < N; i++) {
        long long a,b;
        cin >> a >> b;
        A[i].first = a;
        A[i].second = b;
    }
    sort(A.begin(),A.end());
    long long ans = 0;
    long long cnt = 0;
    while(M != 0) {
        if(M > A[cnt].second) {
            ans+=A[cnt].first*A[cnt].second;
            M-=A[cnt].second;
        }
        else {
            ans+=M*A[cnt].first;
            M = 0;
        }
        cnt++;
    }
    cout << ans << endl;
}


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

int main() {
    string s;cin>>s;
    int n=s.size();
    int mod=1e9+7;
    ll dp[n+1][13]{};
    dp[0][0]=1;
    for (int i=0;i<n;i++)
        for (int j=0;j<13;j++)
            for (int k=0;k<=9;k++)
                if (s[i]=='?'||s[i]-'0'==k)
                    dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
    cout<<dp[n][5]<<endl;
    return 0;
}

Measured memory_bytes: 10624
object Main{
  def main(args:Array[String]) = {
    val list = scala.io.StdIn.readLine.split(" ").map(_.toInt).toList;
    val l = scala.io.StdIn.readLine.split(" ").map(_.toInt).toList.sortWith(_>_);

    println(l.take(list(1)).sum)
  }
}

Measured memory_bytes: 25676
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int A, B, C, K; std::cin >> A >> B >> C >> K;
  std::cout << A+B+C-std::max({A,B,C})+std::max({A,B,C})*std::pow(2,K) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int n;
  cin>>n;
  int f=0,t=n;
  while(t>0){
    f+=t%10;
    t/=10;
  }
  if(n%f==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

//INSERT ABOVE HERE
Int calc(Int x){
  Int res=0;
  for(Int i=50;i>0;i--){
    Int s=(1LL<<i)-1;
    Int y=x&s;
    if((x>>i)&1){
      if(~y&1) res^=(1LL<<i);
    }
  }
  if(((x+1)/2)&1) res^=1;
  //cout<<x<<":"<<res<<endl;
  return res;
}
signed main(){
  Int a,b;
  cin>>a>>b;
  if(a>0) a--;
  cout<<(calc(b)^calc(a))<<endl;;
  return 0;
}


Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
# print(A)

heapq.heapify(A)  # リストaのheap化
# heapq.heappush(a, x)  # heap化されたリストaに要素xを追加
# heapq.heappop(a)  # heap化されたリストaから最小値を削除＆その最小値を出力

for _ in range(M):
    B = -heapq.heappop(A)
    # print(B)
    heapq.heappush(A, -(B//2))

print(-sum(A))


Measured memory_bytes: 72088