akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int main()
{
  int n;
  cin >> n;
  set<int> s;
  vi v(n);
  rep(i,n){
  cin >>v[i];
  }
  int a;
  rep(i,n){
    a=v[i];
    auto num=s.find(a);
    if(num != s.end()){
   	s.erase(a);
    }else{
    s.insert(a);
    }
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 5248
import sys
a, b = map(int, input().split())
c = 0
s = 1

if b == 1:
    print(0)
    sys.exit()

while True:
    for e in range(s):
        c += 1
        s = s - 1 + a
        if s >= b:
            print(c)
            break
    else:
        continue
    break


Measured memory_bytes: 61808
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int K, S;
signed main()
{
    K = read(), S = read();
    int ans = 0;
    for (ri i = 0; i <= K; ++i) {
        for (ri j = 0; j <= K; ++j) {
            int k = S - i - j;
            if (k >= 0 && k <= K) {
                ans++;
            }
        }
    }
    writeln(ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		final String key = br.readLine();
		int count = 0;
		loop:
		while(true){
			final String[] strs = br.readLine().split(" ");
			for(int i = 0; i < strs.length; i++){
			    final String str = strs[i];
				if(str.equals("END_OF_TEXT")){
					break loop;
				} else if(str.equalsIgnoreCase(key)){
					count++; 
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17044
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	string s;
	cin>>s;
	int p = s.size ();
	
	int x=p/2;
	
	for(int i=0;i<x;i++)
	if(s[i]==s[p-i-1])
	cout<<"Yes";
	else
	cout<<"No";
	
	
	
	
	
}

Measured memory_bytes: 256
n=int(input())
red=[list(map(int,input().split())) for _ in range(n)]
blue=[list(map(int,input().split())) for _ in range(n)]
red.sort()
blue.sort()
 
p=0
for bb in blue:
  lis=[-1,-1]
  for rr in red:
    if rr[0]<bb[0] and rr[1]<bb[1] and lis[1]<rr[1]:
      lis=rr
  if lis!=[-1,-1]:
    red.remove(lis)
    p+=1
print(p)

Measured memory_bytes: 3064
// Example program
#include <iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
  int n,l;//n數量,l長度
  string a[100];
  cin>>n>>l;
  for(int i = 0; i < n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i = 0; i < n; i++){
    cout<<a[i];
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == t[i]) ans += 1;
	}
	cout << ans << endl;
}


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

int x(int b[])
{
    if(b[0]+b[1]+b[2]+b[3]<7)return 0;
    else if(b[0]+b[1]+b[2]+b[3]==7)return 1;
    else
    {
        if(b[0]+b[1]-b[2]-b[3]==7)return 2;
        if(b[0]+b[2]-b[3]-b[1]==7)return 3;
        if(b[0]+b[3]-b[1]-b[2]==7)return 4;
        if(b[0]+b[1]+b[2]-b[3]==7)return 5;
        if(b[0]+b[1]+b[3]-b[2]==7)return 6;
        if(b[0]+b[2]+b[3]-b[1]==7)return 7;
    }
}

int main()
{
    string a;
    int i,j;
    int b[4];
    while(cin>>a)
    {
        for(i=0;i<4;++i)
        {
            for(j=0;j<10;++j)
            {
                if(a[i]==48+j)b[i]=j;
            }

        }
        if(x(b)==1)cout<<b[0]<<"+"<<b[1]<<"+"<<b[2]<<"+"<<b[3]<<"=7"<<endl;
        if(x(b)==2)cout<<b[0]<<"+"<<b[1]<<"-"<<b[2]<<"-"<<b[3]<<"=7"<<endl;
        if(x(b)==3)cout<<b[0]<<"-"<<b[1]<<"+"<<b[2]<<"-"<<b[3]<<"=7"<<endl;
        if(x(b)==4)cout<<b[0]<<"-"<<b[1]<<"-"<<b[2]<<"+"<<b[3]<<"=7"<<endl;
        if(x(b)==5)cout<<b[0]<<"+"<<b[1]<<"+"<<b[2]<<"-"<<b[3]<<"=7"<<endl;
        if(x(b)==6)cout<<b[0]<<"+"<<b[1]<<"-"<<b[2]<<"+"<<b[3]<<"=7"<<endl;
        if(x(b)==7)cout<<b[0]<<"-"<<b[1]<<"+"<<b[2]<<"+"<<b[3]<<"=7"<<endl;


    }


}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll a;
    cin >> a;
    cout << (a * (1 + (a * (1 + a)))) << endl;
}

int main() {
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;

    std::string s;
    std::cin >> s;

    std::string alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    for (auto c : s) {

        std::cout << alphabets[(c - 'A' + n) % alphabets.size()];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << 0 + abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
vector<ll>G[200005];
ll ans[200005];
int main() {
	ll n, q;
	cin >> n >> q;
	
	int a, b;
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	ll index,value;
	for (int i = 0; i < q; i++) {
		cin >>index>>value;
		index--;
		ans[index] += value;
	}

	queue<ll>que;
	vector<ll>dist(n, inf);
	vector<ll>pre(n - 1, -1);
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int x = que.front();
		que.pop();
		for (auto id : G[x]) {
			if (dist[id] != inf) {
				continue;
			}
			dist[id] = dist[x] + 1;
			ans[id] += ans[x];
			que.push(id);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 22180
//dhruv
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
const int inf = 1e18 + 5;
 
template<typename T>
T binpow(T a,T b,T modi){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a)%modi;
		}
		b /= 2;
		(a *= a) %= modi;
	}
	return res;
}
 
 
template<typename T>
T binpow(T a,T b){
	T res = 1;
	while(b){
		if(b&1){
			res = (res*a);
		}
		b /= 2;
		a *= a;
	}
	return res;
}
 
template<typename T>
T add(T a,T b){
	return (a + b)%mod;
}
template<typename T>
T sub(T a,T b){
	return add(a,mod - b);
}
template<typename T>
T mul(T a,T b){
	return (a*b)%mod;
}
template<typename T>
T inv(T a){
	return binpow(a,mod - 2,mod);
}

int make_int(string s){
	int x = 0;
	reverse(s.begin(),s.end());
	string tmp = s;
	for(int i = 0;i < s.length(); ++i){
		x *= 10;
		x += (int)(tmp.back() - '0');
		tmp.pop_back();
	}
	return x;
}
 
string make_string(int s){
	string x;
	while(s){
		x.push_back(char(s%10 + '0'));
		s /= 10;
	}
	reverse(x.begin(),x.end());
	return x;
}

random_device rd;
mt19937 g(rd());

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

const int N = 100;

vi fact;

void factorial(){
	fact.resize(N);
	fact[0] = 1,fact[1] = 1;
	fro(i,2,N){
		fact[i] = (fact[i - 1]*i)%mod;
	}
}

int nCr(int n,int r){
	return (mul(fact[n],inv(mul(fact[r],fact[n - r]))));
}

int nPr(int n,int r){
	return(mul(nCr(n,r),fact[r]));
}

// Linear Seive


int lp[N + 1];
vector<int> pr;
void ls(){
	for(int i = 2;i <= N; ++i){
		// means prime
		if(lp[i] == 0){
			lp[i] = i;
			pr.push_back(i);
		}
		for(int j = 0;j < pr.size() && pr[j] <= lp[i] && i*pr[j] <= N; j++){
			lp[i*pr[j]] = pr[j];
		}
	}
}


// getting the prime factorisation

vector<int> getfc(int n){
	vi factors;
	while(n != 1){
		int x = lp[n];
		factors.push_back(x);
		while(n%x == 0){
			n /= x;
		}
	}
	return factors;
}

int gcd(int a,int b){
	while(b){
		a %= b;
		swap(a,b);
	}	
	return a;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	// shuffle(all(a),g);
	int n;
	cin >> n;
	vi a(n);
	int cnt1 = 0;
	vector<int> cnt(1e6 + 6);	
	ffor(i,n){
		cin >> a[i];
		if(cnt[a[i]] != 0){
			cnt[a[i]] = 2;
		}else{
			cnt[a[i]]++;
		}
		cnt1 += (a[i] == 1);
	}
	if(cnt1 == 1){
		cout << 1;
		return 0;
	}else if(cnt1 >= 2){
		cout << 0;
		return 0;
	}
	sort(all(a));
	for(int i = 0;i < n; ++i){
		for(int x = 2*a[i];x <= 1e6 + 5;x += a[i]){
			cnt[x]++;
		}
	}

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

	cout << ans;
	return 0;
}	


Measured memory_bytes: 12696
#include <iostream>
#include <algorithm>
#include <cmath>
int main()
{
  int W, a, b, _, __;
  std::cin >> W >> a >> b; _=a-b-W; __=a+W-b;
  std::cout<<(((a<=b&&b<=a+W)||(a<=b+W&&b+W<=a+W))
  ?0:std::min(_*((_>0)-(_<0)),__*((__>0)-(__<0))))<<std::endl;
  return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N;
    map<string, ll> m;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        string S;
        cin >> S;
        m[S]++;
    }
    cout << m.size() << endl;
    return 0;
}


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

vector<vector<int>> to(55);
map<int,pair<int,int>> id;
vector<int> flag(55,false);

void dfs(int a,pair<int,int> memo,int r=-1){
    if(flag[a]);
    else if(memo==make_pair(min(a,r),max(a,r)));
    else{
        flag[a]=true;
        for(auto p:to[a]){
            if(p==r)continue;
            dfs(p,memo,a);
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    int cnt=0;
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
        id[i]=make_pair(a,b);
    }
    flag.resize(n);
    for(int i=0; i<m; i++){
        bool fail=false;
        dfs(0,id[i]);
        for(int j=0; j<n; j++){
            if(!flag[j])fail=true;
            flag[j]=false;
        }
        if(fail)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdint.h>
#define ff first
#define ss second

using namespace std;


#define MOD 1e9+7
#define ll long long int


void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int> v(n+1);
	for(int i=0;i<k;i++)
	{
		int d;
		cin>>d;
		for(int i=0;i<d;i++)
		{
			int xx;
			cin>>xx;
			v[xx]++;
		}
	}
	int aa=0;
	for(int i=1;i<=n;i++)
		if(v[i]==0)
			aa++;
	cout<<aa<<"\n";
}



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

	#ifndef ONLINE_JUDGE 
      	freopen("_input.txt", "r", stdin); 
  	freopen("_output.txt", "w", stdout); 
  	#endif 
	

    solve();

	
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    ll s;
    cin >> s;
    ll m = 1e9;
    cout << 0 << " " << 0 << " " << m << " " << 1 << " ";
    ll y = s / m;
    if(s % m != 0) y++;
    ll x = m * y - s;
    cout << x << " " << y << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(s, k):
    ret = 0
    rev = 0
    c = s[0]
    for i in range(1, len(s)):
        if s[i] == c:
            ret += 1
            continue
        rev += 1
        c = s[i]
    ret += min(rev, k*2)
    k -= rev//2
    return ret


def main():
    n, k = rli()
    s = input()
    rs = ""
    for i in range(len(s)):
        if (s[n-i-1] == 'L'): rs += 'R'
        else: rs += 'L'
    a1 = calc(s,k)
    a2 = calc(rs,k)
    # print(s)
    # print(rs)
    print(max(a1, a2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
n = int(input())
a = list(map(int, input().split()))
m,p = 0,0
a.sort()
if len(a)%2==0:
    for i in range(0,len(a),2):
        m+=a[i]
    for i in range(1,len(a),2):
        p+=a[i]
else:
    for i in range(0,len(a),2):
        p+=a[i]
    for i in range(1,len(a),2):
        m+=a[i]
print(p-m)

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

int main() {
    int n;
    int m;
     
   
   cin >> n >> m;
   int sum = n + m;
   int ans = sum/2;
    

    
    
  if (sum % 2 == 0) {
cout << ans << endl;
} else {
cout << ans + 1 << endl;
}
  
  

  
  return 0;
}

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

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

const int MAXN = 1e5 + 7;

void pudge(){
    char x;
    cin >> x;
    cout << char(x + 1);
}

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

    int q = 1;
    //cin >> q;
    while(q--) pudge();

    return 0;
}


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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "YES"
#define NO  "NO"

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  char c; cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') flag = true;

  cout << (flag ? "vowel" : "consonant") << endl;

  // cout << num << endl;
  // cout << (flag ? "H" : "D") << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
As = list(map(str, input().split()))

from collections import deque
b = []
b = deque(b)

for i, a in enumerate(As):
    if i%2==0:
        b.append(a)
    else:
        b.appendleft(a)

if n%2==0:
    print(' '.join(b))
else:
    print(' '.join(reversed(b)))

Measured memory_bytes: 27460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int x, y;
  cin >> x >> y;
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if(a[x] == a[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n,k;
    cin>>n>>k;
    int b=0;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    REP(i,n){
    if(a[i]<=k/2){
        b+=a[i]*2;
    }else{
        b+=(k-a[i])*2;
    }
    }
cout<<b;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int n,x,res;
 
	while(1){
	res = 0;
	cin >> n >> x;
	if(n == 0 && x == 0)break;
	for(int i = 1; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			for(int k = j+1; k <= n; k++){
				if(i + k + j == x){
					res++;
				}
 
			}
		}
	}
	cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

const int mod = 1000000007;
int main() {
	int N;
	scanf("%d", &N);
	struct Data {
		int c, s, f;
	}*d = new Data[N - 1];
	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d %d", &d[i].c, &d[i].s, &d[i].f);
	}
	for (int i = 0; i < N; i++) {
		int t = 0;
		for (int j = i; j < N - 1; j++) {
			int r = ((t - 1) / d[j].f + 1)*d[j].f;
			if (t == 0)r = 0;
			t = (r < d[j].s ? d[j].s : r) + d[j].c;
		}
		printf("%d\n", t);
	}
}





Measured memory_bytes: 256
if __name__ == "__main__":

    param = input()
    char = [c for c in param]

    n = int(input())

    for _ in range(n):

        command = input().split(" ")

        if   command[0] == "print":
            str = "".join(char[int(command[1]) : (int(command[2]) + 1)])
            print(str)
        elif command[0] == "reverse":
            part = char[int(command[1]):(int(command[2]) + 1)]
            part.reverse()
            char[int(command[1]):(int(command[2]) + 1)] = part[0:]
        elif command[0] == "replace":
            char[int(command[1]):int(command[2]) + 1] = command[3]
        else:
            pass



Measured memory_bytes: 5628
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int MAX = 100;
	boolean[][] map;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			
			map = new boolean[MAX][MAX];
			for(int i=0;i<n;i++) {
				int m = sc.nextInt();
				for(int j=0;j<m;j++) map[i][sc.nextInt()-1] = true;
			}
			int l = sc.nextInt();
			int[] pr = new int[l];
			for(int i=0;i<l;i++) pr[i] = sc.nextInt()-1;
			
			boolean ans = false;
			int tgt = -1;
			for(int i=0;i<n;i++) {
				boolean flg = true;
				for(int k=0;k<l;k++) {
					if(!map[i][pr[k]]) flg = false;
				}
				if( flg ) {
					if(!ans) {
						ans = true;
						tgt = i+1;
					}
					else {
						ans = false;
						break;
					}
				}
			}
			
			System.out.println( (ans? tgt: -1) );
		}
		
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
//it is coded by ning-mew on 9.28
#include<bits/stdc++.h>
#define LL long long
using namespace std;

LL n,x,ans,g;

LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
int main(){
	scanf("%lld%lld",&n,&x);
	g=gcd(n,x);ans=(n/g-1)*3*g;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int H=sc.nextInt();
			int W=sc.nextInt();
			if(H==0&&W==0) break;
			for(int i=0;i<W;i++){
				System.out.print("#");
			}
			System.out.println();
			for(int i=0;i<H-2;i++){
				System.out.print("#");
				for(int j=0;j<W-2;j++){
					System.out.print(".");
				}
				System.out.print("#");
				System.out.println();
			}
			for(int i=0;i<W;i++){
				System.out.print("#");
			}
			System.out.println();
			System.out.println();
		}
	}
}

Measured memory_bytes: 35000
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n\n').map(function(i){l=/1.*1/.exec(i.replace(/\s/g,''))[0].length;console.log(l==10?'A':l==25?'B':l==4?'C':l==16?'D':l==11?'E':l==9?'G':'F')})

Measured memory_bytes: 7644
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
int _min(int x, int y) {return x < y ? x : y;}
int _max(int x, int y) {return x > y ? x : y;}
LL read() {
	LL s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}

struct edge {
	int x, y, next;
} f[110000], e[110000]; int len, last[110000];
struct node {
	LL x; int id;
} a[110000];
LL d[110000], sum;
int tot[110000];

bool cmp(node a, node b) {return a.x < b.x;}

void ins(int x, int y) {
	e[++len].x = x, e[len].y = y;
	e[len].next = last[x], last[x] = len;
}

void dfs(int x, int dis) {
	sum += dis;
	for(int k = last[x]; k; k = e[k].next) {
		int y = e[k].y;
		dfs(y, dis + 1);
	}
}

int main() {
	LL n = read();
	for(LL i = 1; i <= n; i++) a[i].x = read(), a[i].id = i;
	sort(a + 1, a + n + 1, cmp);
	for(LL i = 1; i <= n; i++) d[i] = a[i].x;
	for(LL i = 1; i <= n; i++) tot[i] = 1;
	len = 0;
	for(LL i = n; i > 1; i--) {
		LL u = d[i] - n + 2 * tot[i];
		int fa = lower_bound(d + 1, d + n + 1, u) - d;
		if(d[fa] != u) {puts("-1"); return 0;}
		f[++len].x = fa, f[len].y = i;
		tot[fa] += tot[i];
	} len = 0; for(int i = 1; i < n; i++) ins(f[i].x, f[i].y);
	sum = 0; dfs(1, 0);
	if(sum != d[1]) {puts("-1"); return 0;}
	for(int i = 1; i < n; i++) printf("%d %d\n", a[f[i].x].id, a[f[i].y].id);
	return 0;
}


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


// Problem https://atcoder.jp/contests/abc075/tasks/abc075_b
// Reference https://atcoder.jp/contests/abc075/submissions/1682902

bool out_this_map(int height,int width,int nowheight,int nowwidth){
    bool result;
    result = false;
    if(nowheight<0){
        return true;
    }
    if(nowwidth<0){
        return true;
    }
    if((height-1)<nowheight){
        return true;
    }
    if((width-1)<nowwidth){
        return true;
    }
    return result;
}

vector<vector<int>> solver(int height,int width,vector<string> problemMap){
    vector<vector<int>> result(height,vector<int> (width,0));
    vector<int> dx ={0,1,1,1,0,-1,-1,-1};
    vector<int> dy={1,1,0,-1,-1,-1,0,1};
    for(int j=0;j<height;j++){
        for(int k=0;k<width;k++){
            if(problemMap.at(j).at(k) == '#'){
                result.at(j).at(k)=9;
                continue;
            }
            for(int dir=0;dir < 8;dir++){
                int checkheight;
                checkheight=j+dy.at(dir);
                int checkwidth;
                checkwidth=k+dx.at(dir);
                if(out_this_map(height,width,checkheight,checkwidth)){
                    continue;
                }
                if(problemMap.at(checkheight).at(checkwidth) == '#')
                    {
                    result.at(j).at(k)=result.at(j).at(k)+1;
                    }
            }
        }
    }

    return result;
}


int main(void){
    int H,W;
    cin >> H >> W;
    vector<string> problemMap;
    for(int j=0;j<H;j++){
        string oneLine;
        cin >> oneLine;
        problemMap.push_back(oneLine);
    }
    vector<vector<int>> answer(H,vector<int> (W,0));
    answer = solver(H,W,problemMap);
    for(int j=0;j<H;j++){
        for(int k=0;k<W;k++){
            if(answer.at(j).at(k)==9){
                cout << "#";
            }
            else
            {
                cout << answer.at(j).at(k);
            }
        }
        cout << endl;
    }   
    return 0;
}


Measured memory_bytes: 256
def main():
  n = int(input())
  k = int(input())
  x = list(map(int,input().split()))
  sum=0
  for i in range(0,n):
    if abs(x[i]-0)>abs(k-x[i]):
      sum+=abs(k-x[i])*2
    else:
      sum+=abs(x[i]-0)*2
  print(sum)
    
main()

Measured memory_bytes: 9036
#include <cstdio>
#include <queue>
#define MAXN 100005
#define INF 1e9
using namespace std;
queue <int> q;
struct Edge{
	int next,to,w;
}edge[MAXN<<2];
int n,m,cnt,head[MAXN],tot[MAXN],dis[MAXN];
bool vis[MAXN],flag,checked[MAXN];
inline void add(int u,int v,int w){
	edge[++cnt].next=head[u];
	edge[cnt].to=v;
	edge[cnt].w=w;
	head[u]=cnt;
}
bool spfa(int s){
	vis[s]=1;
	dis[s]=0;
	q.push(s);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=head[u];i;i=edge[i].next){
			int v=edge[i].to;
			if(dis[v]==INF){
				dis[v]=dis[u]+edge[i].w;
				checked[v]=1;
				if(!vis[v])
					q.push(v);
			} else if(dis[v]!=dis[u]+edge[i].w) return 0;
		}
		vis[u]=0;
	}
	return 1;
}
int main(){
	scanf("%d %d",&n,&m);
	for(register int i=1;i<=n;++i)
		dis[i]=INF;
	for(register int i=1;i<=m;++i){
		int u,v,w;
		scanf("%d %d %d",&u,&v,&w);
		add(u,v,w);
		add(v,u,-w);
	}
	for(register int i=1;i<=n;++i)
		if(!checked[i]){
			bool ret=spfa(i);
			checked[i]=1;
			if(!ret){
				printf("No\n");
				return 0;
			}
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll N,ans,B;cin>>N;
    ans=0;
    vector<ll>v(N);
    rep(i,N){
             cin>>v[i];
             }
    rep(i,N-1){
                rep(j,i+1,N){
                                B=v[i]*v[j];
                                ans=ans+B;                                
                           }
               }
               cout<<ans<<endl;
                           
    

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int main()
{
  int n,i,j;
  string messenger,m;
  cin>>n;
  while(n-->0){
    cin>>messenger>>m;
    for(i=messenger.size();i-->0;){
      switch(messenger[i]){
        case 'J':
	  m=m[m.size()-1]+m.substr(0,m.size()-1);
	  break;
        case 'C':
	  m=m.substr(1,m.size()-1)+m[0];
	  break;
        case 'E':
	  if(m.size()&1)m=m.substr(m.size()/2+1,m.size()/2)+m[m.size()/2]+m.substr(0,m.size()/2);
	  else m=m.substr(m.size()/2,m.size()/2)+m.substr(0,m.size()/2);
	  break;
        case 'A':
	  reverse(m.begin(),m.end());
	  break;
        case 'P':
	  for(j=0;j<m.size();j++)if(isdigit(m[j]))m[j]=(m[j]-'0'+9)%10+'0';
	  break;
        case 'M':
	  for(j=0;j<m.size();j++)if(isdigit(m[j]))m[j]=(m[j]-'0'+1)%10+'0';
	  break;
      }
    }
    cout<<m<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	long long A[5] = {0,0,0,0,0};
	cin >> N;
	vector<string> S(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> S.at(i);
		if (S.at(i).at(0) == 'M')
		{
			A[0]++;
		}
		else if (S.at(i).at(0) == 'A')
		{
			A[1]++;
		}
		else if (S.at(i).at(0) == 'R')
		{
			A[2]++;
		}
		else if (S.at(i).at(0) == 'C')
		{
			A[3]++;
		}
		else if (S.at(i).at(0) == 'H')
		{
			A[4]++;
		}
	}
		long long ans=0;
		for (size_t i = 0; i < 5; i++)
		{
			for (size_t j = i+1; j < 5; j++)
			{
				for (size_t k = j+1; k < 5; k++)
				{
					ans += A[i] * A[j] * A[k];
				}
			}
		}
		
	cout << ans;
	}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    double a,b,x;
    int c;
    cin >> a >> b;
    x = (a+b)/2;
    c = x;
    if(x > c) c++;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

if S[0] == 'R':
    if S[1] == 'R':
        if S[2] == 'R':
            print(3)
        else:
            print(2)
    else:
        print(1)
else:
    if S[1] == 'R':
        if S[2] == 'R':
            print(2)
        else:
            print(1)
    else:
        if S[2] == 'R':
            print(1)
        else:
            print(0)

Measured memory_bytes: 8924
#include <bits/stdc++.h>
using namespace std;
#define jaldi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define kuch(a,n) for(ll i=0;i<n;i++) cin>>a[i]
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define bs(v,x)	binary_search(v.begin(),v.end(),x)
#define mci(b)	cout<<b<<"\n"
#define bvb(n)	long long n;cin>>n;

typedef long long ll;
typedef vector<long long> vll ;
typedef long double ld;
const ll maxn = 1e9, mod = 1e9 + 7;


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

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

int main()
{
	jaldi;
	int n;
    cin>>n;
    vector<int> dp(3);

    for(int day = 0; day < n; ++day) {
        vector<int> dp1(3, 0);
        int arr[3];
        kuch(arr,3);
        
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(i != j) {
                    dp1[j] = max(dp1[j], dp[i] + arr[j]);
                }
            }
            //mci(dp[i]);
        }
        dp = dp1;
    }
    cout<<Max(dp[0], dp[1], dp[2])<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	long long N,B[1000],A[1000],i,s;
	scanf("%lld",&N);
	for(i=0;i<N-1;i++)
	{
		scanf("%lld",&B[i]);
	}
	A[0]=B[0];
	A[N-1]=B[N-2];
	for(i=1;i<N-1;i++)
	{
		if(B[i-1]<B[i])
		{
			A[i]=B[i-1];
		}
		else
		{
			A[i]=B[i];
		}
	}
	for(i=0,s=0;i<N;i++)
	{
		s=s+A[i];
	}
	printf("%lld",s);
	return 0;
}

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

namespace AtCoder {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static long cln(long D = -1) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return long.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			var Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		static string read() { return Console.ReadLine(); }
		#endregion

		static void Main(string[] args) {
			var yak = new Regex("^YAKI");
			var S = Console.ReadLine();
			print(yak.IsMatch(S)?"Yes":"No");
		}
	}
}


Measured memory_bytes: 15980
#!/usr/bin/env python3
import sys
import copy
line = sys.stdin.readline() 
line = line.rstrip('\r\n')
face = line.split()

line = sys.stdin.readline() 
line = line.rstrip('\r\n')

for i in line:
    face_old = copy.deepcopy(face)
    if i == "E":
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]
    elif i == "N":
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    elif i == "S":
        face[0] = face_old[4]
        face[1] = face_old[0]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[5]
        face[5] = face_old[1]
    else:
        face[0] = face_old[2]
        face[1] = face_old[1]
        face[2] = face_old[5]
        face[3] = face_old[0]
        face[4] = face_old[4]
        face[5] = face_old[3]

print(face[0])



Measured memory_bytes: 6312
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

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

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


void harmony()
{
  int a, b;
  cin >> a >> b;

  if (a % 2 == b % 2) cout << (a + b) / 2 << "\n";
  else cout << "IMPOSSIBLE\n";
}


void transfer()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << "\n";
}


void A_137()
{
  int a, b;
  cin >> a >> b;

  cout << max(a + b, max(a - b, a * b)) << "\n";
}


void red_or_not()
{
  int a;
  cin >> a;
  string s;
  cin >> s;

  if (a >= 3200) cout << s << "\n";
  else cout << "red\n";
}


void tenki()
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  for (int i = 0; i < 3; ++i)
  {
    if (s[i] == t[i]) ++cnt;
  }
  cout << cnt << "\n";
}


void password()
{
  int n;
  cin >> n;

  cout << pow(n, 3) << "\n";
}



int main()
{
  //security();
  //fifty_fify();
  //dodecagon();
  //harmony();
  //transfer();
  //A_137();
  //red_or_not();
  //tenki();
  password();
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int x[b], y[a];
  if(a >= b) {
    for(int i = 0; i < a; i++) {
      y[i] = b;
      cout << y[i];
    }
  }
  if(a < b) {
    for(int i = 0; i < b; i++) {
      x[i] = a;
      cout << x[i];
    }
  }
}

Measured memory_bytes: 764
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String result = "";
		for(int i=0; i<s.length(); i++){
			switch(s.charAt(i)){
			case '0':
				result += 0;
				break;
			case '1':
				result += 1;
				break;
			case'B':
				if(!result.isEmpty()){
					result = result.substring(0, result.length() - 1);
				}
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 38460
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

  mint ans;
  vector<mint> dp(s+1);
  rep(_,n){
    int a;
    cin >> a;
    dp[0] += 1;
    vector<mint> temp(s+1);
    rep(i,s+1){
      temp[i] += dp[i];
      if(i+a<=s) temp[i+a] += dp[i];
    }
    dp = temp;
    ans += dp[s];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
int a[100000], b[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void ShowData(int x[], int left,int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort2(int x[],int y[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		hSwap(y, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort2(x,y, left, i - 1, n);
	if (j + 1 <  right)QSort2(x,y, j + 1, right, n);
}


int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n) {
		scanf("%d%d", &a[i], &b[i]);
	}
	QSort2(a, b, 0, n - 1,1);

	ll ans = 0;
	REP(i, n) {
		if (m >= b[i]) {
			m -= b[i];
			ans += (ll)a[i]*b[i];
		}
		else {
			ans += (ll)m*a[i];
			break;
		}
	}
	PRINTL(ans);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pil pair<int,LL> 
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define node(a,b,c) (node){a,b,c}
using namespace std;
const int inf=1e9,mod=1e9+7;
int n,Q,sl,fh,rt_num,rt[mxn],dep[mxn],f[mxn][20];
LL ans,dis[mxn];
int t,h[mxn];
struct Tre
{
	int to,col,val,nxt;
}e[mxn<<1];
struct seg
{
	LL sum;int num;
	int l,r;
}tr[mxn<<4];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void add(int u,int v,int c,int w)
{
	e[++t]=(Tre){v,c,w,h[u]};h[u]=t;
	e[++t]=(Tre){u,c,w,h[v]};h[v]=t;
}
#define mid ((l+r)>>1)
void update(int &x,int l,int r,int p,int v)
{
	tr[++rt_num]=tr[x];x=rt_num;
	if(l==r) {tr[x].num++; tr[x].sum+=v; return ;}
	if(p<=mid) update(tr[x].l,l,mid,p,v);
	else update(tr[x].r,mid+1,r,p,v);
}
pil query(int x,int l,int r,int p)
{
	if(!x) return mp(0,0ll);
	if(l==r) return mp(tr[x].num,tr[x].sum);
	if(p<=mid) return query(tr[x].l,l,mid,p);
	else return query(tr[x].r,mid+1,r,p);
}
void dfs(int u)
{
	for(int i=1;i<20;++i) f[u][i]=f[f[u][i-1]][i-1];
	int v;
	for(int i=h[u];i;i=e[i].nxt)
		if((v=e[i].to)!=f[u][0])
		{
			rt[v]=rt[u];f[v][0]=u;dep[v]=dep[u]+1;dis[v]=dis[u]+e[i].val;
			update(rt[v],1,n,e[i].col,e[i].val);
			dfs(v);
		}
}
int lca(int u,int v)
{
	if(dep[u]<dep[v]) swap(u,v);
	for(int i=19;~i;--i)
		if(dep[f[u][i]]>=dep[v])
			u=f[u][i];
	if(u==v) return u;
	for(int i=19;~i;--i)
		if(f[u][i]!=f[v][i])
			u=f[u][i],v=f[v][i];
	return f[u][0];
}
int main()
{
	n=rd();Q=rd();int x,y,c,z;pil retx,rety,retz;
	for(int i=1;i<n;++i) x=rd(),y=rd(),c=rd(),z=rd(),add(x,y,c,z);
	dep[1]=1;dfs(1);
	for(int w;Q;--Q)
	{
		c=rd();w=rd();x=rd();y=rd();z=lca(x,y);
		retx=query(rt[x],1,n,c);rety=query(rt[y],1,n,c);retz=query(rt[z],1,n,c);
		ans=dis[x]+dis[y]-2*dis[z]-(retx.sc+rety.sc-2*retz.sc)+1ll*w*(retx.fr+rety.fr-2*retz.fr);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 67840
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll a;
  string s;
  cin>>a>>s;
  if(a>=3200){cout<<s<<endl;}
  else{cout<<"red"<<endl;}
  
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    string S;
    cin >> S;
    ll sum = 0;
    for (ll i = 0; i < S.length(); i++) {
        sum += (int)S.at(i) - '0';
        //cout << (int)S.at(i) - '0' << endl;
    }
    //cout << sum % 9 << endl;
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<int, ll> P;

bool visited[110000];
ll dp[110000];
vector<vector<P>> to(110000, vector<P>());

bool bfs(int i) {
    if (visited[i]) return true;

    visited[i] = true;
    dp[i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (auto p: to[v]) {
            if (visited[p.first]) {
                if (dp[p.first] != dp[v] + p.second) return false;
            } else {
                dp[p.first] = dp[v] + p.second;
                visited[p.first] = true;
                q.push(p.first);
            }
        }
    }

    return true;
}

int main() {
    ll N, M;
    cin >> N >> M;
    rep(i, M) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        l--;
        r--;
        to[l].push_back(make_pair(r, d));
        to[r].push_back(make_pair(l, -1L * d));
    }

    rep(i, N) {
        if (!bfs(i)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll A, B;
int main(){
	cin >> A >> B;
	ll sum=A;
	if(B==1)p(0);
	else{
		REP(i,1,400){
			if(sum >= B) {
				p(i);
				break;
			}
			sum += A-1;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  cin>>a;
  if(a==9||a==19||a==29||a==39||a==49||a==59||a==69||a==79||a==89||a/10==9){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}
  

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

using namespace std;
 
int main() {
    int r;cin>>r;
    if(r <1200) cout<<"ABC";
    else if(r <2800) cout<<"ARC";
    else cout<<"AGC";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll K, N;
vector<double> p(200010);
double ans = 0, tmp = 0;

int main() {
    cin >> N >> K;
    rep(i, N) cin >> p[i];

    rep(i, K) {
        //まず最初にぶっこむ
        ans += (1 + p[i]) / 2;
        tmp += (1 + p[i]) / 2;
        //cout << (1 + p[i]) / 2 << endl;
    }

    //double tmp = ans;
    REP(i, K, N) {
        tmp -= (1 + p[i - K]) / 2;
        tmp += (1 + p[i]) / 2;
        ans = max(ans, tmp);
        //cout << ans << endl;
    }

    cout << fixed << setprecision(6) << ans << endl;
}

Measured memory_bytes: 4692