akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int K;
LL MOD=1e9+7;
LL ans[100011];

LL pow(LL x, LL b){
	LL ans=1;
	LL now=x;
	while(b!=0){
		if(b%2==0){
			ans*=now;
			ans%=MOD;
		}
		now*=now;
		now%=MOD;
		b/=2;
	}
	return ans;
}

int main(){
	cin>>K;
	N=3;
	REP(i,K+1){
		ans[i]=0;
	}
	for(int i=K;i>=1;i--){
		vector<int>v;
		v.clear();
		for(int j=1;j*j<=i;j++){
			if(i%(j)==0){
				v.push_back(j);
				v.push_back(i/j);
			}
		}
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		LL now=K/i;
		LL tmp=pow(now,N);
		//cout<<"now"<<now<<" "<<N<<" "<<tmp<<endl;
		ans[i]+=tmp;
		ans[i]%=MOD;
		/*REP(j,3){
			cout<<ans[j]<<endl;
		}*/
		REP(j,v.size()){
			if(i!=v[j]){
				ans[v[j]]+=MOD-ans[i];
				ans[v[j]]%=MOD;
			}
		}
		/*REP(j,10){
			cout<<ans[j]<<endl;
		}
		cout<<endl;
		*/
	}
	LL answer=0;
	REP(i,K+1){
		answer+=(ans[i]*i);
		answer%=MOD;
	}
	cout<<answer<<endl;
}

Measured memory_bytes: 4136
class Tree
  @@nodes = {}
  def self.root
    @@nodes[1]
  end
  def self.make!
    self.root.make(nil)
    visited = [self.root]
    visited.each do |parent|
      parent.children.each do |child|
        child.make(parent)
        visited.push(child)
      end
    end
  end
  def self.node(id)
    @@nodes[id]
  end
  def self.make_count!
    visited = [self.root]
    visited.each do |parent|
      parent.children.each do |child|
        child.plus(parent.count)
        visited.push(child)
      end
    end
  end
  attr_reader :id, :edges, :children, :count
  def initialize(id)
    @id = id
    @parent = nil
    @children = []
    @edges = []
    @count = 0
    @@nodes[id] = self
  end
  def add(id)
    @edges.push(Tree.node(id))
  end
  def plus(count)
    @count += count
    # puts "#{@id}: +#{count}"
  end
  def make(parent)
    @parent = parent
    @edges.delete(parent)
    @children = @edges
  end
end

N,Q = gets.split.map(&:to_i)
(1..N).each{|i| Tree.new(i)}

(N-1).times do
  a,b = gets.split.map(&:to_i)
  Tree.node(a).add(b)
  Tree.node(b).add(a)
end
Tree.make!

Q.times do
  p,x = gets.split.map(&:to_i)
  Tree.node(p).plus(x)
end
Tree.make_count!

(1..N).each do |i|
  print "#{Tree.node(i).count} "
end
puts

Measured memory_bytes: 70240
#include<iostream>
using namespace std;
int main(){
    int a;
    cin>>a;
    for(int i=1;i<=a;i++){
        int x=i;
        if(x%3==0){
            cout<<" "<<i;
        }
        else{
            while(x){
                if(x%10 ==3){
                    cout<<" "<<i;
                    break;
                }
                x /=10;
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3080
import sys
a = 0
b = 0
ab = 0
o = 0
for i in sys.stdin.readlines():
    if i.find(",AB") > -1:
        ab += 1
    elif i.find(",B") > -1:
        b += 1
    elif i.find(",A") >-1:
        a += 1
    else:
        o += 1
print(a)
print(b)
print(ab)
print(o)

Measured memory_bytes: 7344
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    ll X;

    cin >> X;

    for (ll A = -1000; A <= 1000; A++) {
        for (ll B = -1000; B <= 1000; B++) {
            ll a = A * A * A * A * A;
            ll b = B * B * B * B * B;
            if (a - b == X) {
                printf("%lld %lld\n", A, B);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W ;
  vector <string> A (H) ;
  for (int i=0 ; i<H ; i++){
   cin >> A.at(i) ;  
  }
 
  for ( int i=0 ; i<W+2 ;i++){
cout << '#' ;
  }
  cout << endl;
    for (int j=0; j<H ; j++){
      cout << '#' <<  A.at(j)  << '#' << endl;
    }
  for ( int i=0 ; i<W+2 ;i++){
cout << '#' ;
  }
  cout << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int a[100005];
vector <int> Div;

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int ans = a[2];
	for(int i = 3; i <= n; i++)
	{
		ans = __gcd(ans, a[i]);
	}
	for(int i = 1; i <= sqrt(a[1]); i++)
	{
		if(a[1] % i == 0)
		{
			Div.eb(i);
			Div.eb(a[1] / i);
		}
	}
	for(auto x : Div)
	{
		int cnt = 0;
		for(int i = 1; i <= n; i++)
		{
			if(a[i] % x == 0)
			{
				cnt++;
			}
		}
		if(cnt >= n - 1)
		{
			ans = max(ans, x);
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[112345];
    int x = 0;

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        x ^= a[i];
    }

    int res = 0;

    for (int i = 30; i >= 0; i--)
    {
        if (!(x & (1 << i)))
            continue;

        REP(j, n)
        {
            if ((a[j] ^ (a[j] - 1)) == (1 << (i + 1)) - 1)
            {
                res++;
                a[j] = 0;
                x ^= (1 << (i + 1)) - 1;

                break;
            }
        }
    }

    if (x == 0)
        cout << res << endl;
    else
        cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int n;
   cin >> n;
   int ans = n/3;

   cout << ans << endl;




   return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 170
//D - Not Divisible
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

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

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    const int A_MAX = 1e+6 + 1;
    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a));
    map<int, int> m;

    REP(i,n){
        int atmp=a[i];
        while(a[n-1]>=atmp){
            m[atmp]++;
            atmp+=a[i];
        }
    }

    int ans=0;
    REP(i, n){
        if (m[a[i]]==1) ans++;
    }

/*    
    vector<bool> ab(n, true);
    REP(i, n){
        if (ab[i]){
            FOR(j, i+1, n-1){
                if (a[j]%a[i]==0) ab[j]=false;
            }
        }
    }
    REP(i, n){
        if (ab[i]) ans++;
    }
    if (a[0]==a[1]) ans--;
*/
/*    
    REP(i,n){
        bool f=true;
        REP(j,i){
            if (a[i]%a[j]==0) {
                f=false;
                break;
            }
        }
        if (f) ans++;
    }
    if (a[0]==a[1]) ans--;
*/
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 50684
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int AC = 0,WA = 0,TLE = 0,RE = 0;
  string a;
  
  while(cin >> a){
    if(a == "AC"){
      AC++;
    }else if(a == "WA"){
      WA++;
    }else if(a == "TLE"){
      TLE++;
    }else if(a == "RE"){
      RE++;
    }
    
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;;
  cout << "TLE x " << TLE << endl;;
  cout << "RE x " << RE << endl;;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define mod 1000000007
#define PI 3.14159265358979323
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define debug(x) cout<<"Case "<<x<<": "
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	//Did not understood this much
	ll n,k;
	cin>>n>>k;
	ll a[n+5]={0};
	ll dp[k+5]={0};
	dp[0]=1;
	//dp[i] - the numbert of ways such that we have used i candies so far
	rep(i,n)cin>>a[i];
	rep(child,n)
	{
		vll fake(k+1);
		fd(used,k,0)
		{
			ll temp = dp[used];
			ll L = used+1;
			ll R = used+min(a[child],k-used); 
			if(L<=R)
			{
				fake[L]=(fake[L]+temp)%mod;
				if(R+1<=k)
					fake[R+1]=(fake[R+1]-temp+mod)%mod;
			}
		}
		ll prefixSum=0;
		rep(i,k+1)
		{
			prefixSum=(prefixSum+fake[i])%mod;
			dp[i]=(dp[i]+prefixSum)%mod;
		}
	}
	cout<<dp[k]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)cin >> a[i];
  int check = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == check+1)check++;
  }
  if(check == 0)cout << -1 << endl;
  else cout << n-check << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const int INF = 2 << 28;
const int MAX_V = 2 * 100 * 100 + 2;
struct edge{int to, cap, rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, int(G[to].size())});
    G[to].push_back((edge){from, 0, int(G[from].size())-1});
}

int dfs(int v, int t, int f){
    if (v == t) return f;
    used[v] = true;
    for(int i=0;i<G[v].size();i++){
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> field(H);
    for(int i=0;i<H;i++){
        cin >> field[i];
    }

    int si, sj, ti, tj;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(field[i][j] == 'S'){
                si = i;
                sj = j;
                field[i][j] = 'o';
            }else if(field[i][j] == 'T'){
                ti = i;
                tj = j;
                field[i][j] = 'o';
            }
        }
    }
    if(si == ti || sj == tj){
        cout << -1 << endl;
        return 0;
    }


    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(field[i][j] == 'o'){
                int n_ij_in = i * W + j;
                int n_ij = n_ij_in + H * W;
                add_edge(n_ij_in, n_ij, 1);
                for(int k=0;k<W;k++){
                    if(k == j) continue;
                    if(field[i][k] == 'o'){
                        int n_ik = i * W + k;
                        // cout << "a " << i << " " << j << " " << k << endl;
                        add_edge(n_ij, n_ik, 1);
                    }
                }
                for(int k=0;k<H;k++){
                    if(k == i) continue;
                    if(field[k][j] == 'o'){
                        int n_kj = k * W + j;
                        // cout << "b " << i << " " << j << " " << k << endl;
                        add_edge(n_ij, n_kj, 1);
                    }
                }
            }
        }
    }

    cout << max_flow(si * W + sj + H * W, ti * W + tj) << endl;

    return 0;
}

Measured memory_bytes: 64000
def get_input():
    input_data = int(input())
    return input_data

def make_registered_id_set(N):
    registered_id_set = set()
    for i in range(N):
        registered_id = input()
        registered_id_set.add(registered_id)
    return registered_id_set

class SecurityDoor:
    CLOSED = 0
    OPENED = 1
    DUMMY = -1
    def __init__(self, registered_id_set):
        self.flag = SecurityDoor.CLOSED
        self.registered_id_set = registered_id_set

    def check_id(self, user_id):
        if user_id in self.registered_id_set:
            msg = self.change_status() + user_id
        else:
            msg = "Unknown " + user_id
        print(msg)

    def change_status(self):
        if self.flag == SecurityDoor.OPENED:
            self.flag = SecurityDoor.CLOSED
            msg = "Closed by "
        else:
            self.flag = SecurityDoor.OPENED
            msg = "Opened by "
        return msg



if __name__ == "__main__":
    N = get_input()
    registered_id_set = make_registered_id_set(N)
    touch_num = get_input()
    security_door = SecurityDoor(registered_id_set)
    for i in range(touch_num):
        user_id = input()
        security_door.check_id(user_id)




Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

class MST {
private:
	struct node {
		bool done;
		vi to, cost;
		int id, from;
		ll d;
		bool operator<(const node & another) const {
			return !(d != another.d ? d < another.d : id < another.id);
		}
	};
	vector<node> nodes;
	int n;
public:
	vll result;
	MST(vector<vector<P>> data) {
		n = data.size();
		result.resize(n);
		nodes.resize(n);
		Loop(i, n) {
			nodes[i] = { false,{},{}, i, -1, INFLL };
			Loop(j, data[i].size()) {
				nodes[i].to.push_back(data[i][j].first);
				nodes[i].cost.push_back(data[i][j].second);
			}
		}
	}
	void mainfunc(int start) {
		priority_queue<node> pq;
		nodes[start].d = 0;
		pq.push(nodes[start]);
		while (pq.size()) {
			node a = pq.top(); pq.pop();
			if (nodes[a.id].done) continue;
			nodes[a.id].done = true;
			Loop(j, a.to.size()) {
				node* b = &nodes[a.to[j]];
				if ((*b).done) continue;
				if (a.cost[j] < (*b).d) {
					(*b).d = a.cost[j];
					(*b).from = a.id;
					pq.push(*b);
				}
			}
		}
		Loop(i, n) {
			result[i] = nodes[i].d;
		}
	}
};

int main() {
	int n; cin >> n;
	vector<vector<P>> data(n);
	Loop(i, n) {
		Loop(j, n) {
			int x; cin >> x;
			if (x == -1) continue;
			else data[i].push_back({ j,x });
		}
	}
	MST mst(data);
	mst.mainfunc(0);
	ll ans = 0;
	Loop(i, n) {
		ans += mst.result[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3344
#define _USE_MATH_DEFINES
//
#include <bits/stdc++.h>
//
using namespace std;
//
#define krep(i,k,n)      for(int i=k;i<n;++i)
#define rep(i,n)         for(int i=0;i<n;++i)
#define toupp(s)         transform(s.begin(),s.end(),s.begin(),::toupper) // string
#define tolow(s)         transform(s.begin(),s.end(),s.begin(),::tolower) // string
#define pb(v)            push_back(v)
#define all(v)           v.begin(),v.end()
#define mp               make_pair
#define __sort(v)        sort(v.begin(),v.end()) // vector
#define __stable_sort(v) stable_sort(v.begin(),v.end()) // vector
#define __exists(c,v)    (find(all(c), (v)) != (c).end()) // vector
#define __unique(v)      __sort(v);v.erase(unique(v.begin(),v.end()),v.end()) // vector
#define __swap(a, b, tmp)  tmp=a;a=b;b=tmp;
#define __memset(a)      memset(a,0,sizeof(a));
//
#define dumpVar(v)       cerr<<setw(30)<<#v" = ["<<v<<"]"<<endl
#define dumpArr(v, n)    for(int i=0;i<n;++i){cerr<<v[i]<<", ";} cerr<<endl
#define dumpPair(p)      cerr<<"<"<<p.first<<", "<<p.second<<">"<<endl
//
typedef long long              ll;
typedef vector<string>         vs;
typedef vector<double>         vd;
typedef list<int>              li_i;
typedef list<double>           li_d;
typedef vector<int>            vi;
typedef pair<int, int>         pii;
typedef pair<double, double>   pdd;
//

long kaijo(long x);

int main ()
{
	ios::sync_with_stdio ( false );
	//
	/* code start */
	
	vector<char> _c_arr;
	int n;
	long counter = 0;
	cin >> n;
	vi arr;
	vs s_arr;
	
	rep(i,n){
		string str = "";
		rep(j,10){
			char c;
			
			
			cin >> c;
			if(str == ""){
				str = c;
			}else{
				int flag = 1;
				for(int k = 0; k < str.length(); ++k){
					if(str[k] > c){
						string::iterator it = str.begin() + k;
						str.insert(it,c);
						flag = 0;
						break;
					}
				}
				if(flag){
					str = str + c;
				}
			}
			
			
			//dumpVar(str);
		}
		s_arr.pb(str);
		
		
	}
	
	dumpArr(s_arr, n);
	__sort(s_arr);
	dumpArr(s_arr, n);
	
	for(int i = 0; i < n; ++i){
		long same_num = 0;
		long skip_num = 0;
		
		for(int j = i+1; j < n; ++j){
			if(i+1 == j && s_arr[i] == s_arr[j])same_num++;
			if(s_arr[i] == s_arr[j]){
				same_num++;
				skip_num++;
			}
			else break;
		}
		dumpVar(i);
		dumpVar(same_num);
		i+=skip_num;
		counter += same_num *(same_num - 1) / 2;
	}
	cout << counter <<  endl;
	
	/* code end   */
	//
	return 0;
}


long kaijo(long x){
	long tmp = 1;
	krep(i,1,x+1){
		tmp = tmp * i;
	}
	return tmp;
}

/*
3
 3 * 2 * 1  / 2
 4 * 3 * 2 * 1 / 2 /2 

*/

Measured memory_bytes: 6260
def steps(c, s):
    # c: No. of elements,  s: sum of elements
    q, r = divmod(s, 9)
    if r != 0:
        cnt = (c-1) + q
    else:
        cnt = (c-1) + q-1
        r = 9
    return cnt, r

m = int(input())
r0 = 0; ans = 0   
for _ in range(m):
    d, c = map(int, input().split())
    cnt, r = steps(c, d*c)
    ans += cnt
    cnt, r0 = steps(2, r0+r)
    ans += cnt
print(ans-1)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n,m;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
string ans = "CODEFESTIVAL2016";
signed main(){
    string s;
    cin >> s;
    int tmp=0;
    REP(i,s.size()){
        if(s[i] != ans[i]){
            tmp++;
        }
    }
    print(tmp)

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int K,T; cin >> K >> T;
	vector<int> a(T);
	rep(i,T) cin >> a[i];
	sort(a.begin(),a.end(),greater<int>());
	if(K % 2 == 0){
		if(a[0] <= K/2){
			cout << 0 << endl;
			return 0;
		}
		int d = a[0]-K/2;
		int ans = 1;
		rep(i,d-1){
			ans += 2;
		}
		cout << ans << endl;
	}
	else{
		if(a[0] <= K/2 + 1){
			cout << 0 << endl;
			return 0;
		}
		int d = a[0]-K/2-1;
		int ans = 2;
		rep(i,d){
			ans += 2;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

List = sorted(List, key=lambda x:x[1])

time = 0
flg = 0
for i in range(N):
    time+=List[i][0]
    if time>List[i][1]:
        flg+=1
if flg==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55264
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double w = sc.nextDouble();
		double h = sc.nextDouble();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		double area = w * h / 2.0;
		int mlt = x * 2 == w && y * 2 == h ? 1 : 0;
		System.out.printf("%f %d\n", area, mlt);
		
		sc.close();
	}
}




Measured memory_bytes: 28960
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int main() {
	int a, v, b, w, t;
	read(a), read(v), read(b), read(w), read(t);
	int dist = abs(a - b);
	if (v > w && 1ll * t * (v - w) >= dist) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (true) {
            int a = scanner.nextInt();
            String op = scanner.next();
            int b = scanner.nextInt();
            if (op.equals("?")) {
                break;
            }
            int x = 0;
            if (op.equals("+")) {
                x = a + b;
            } else if (op.equals("-")) {
                x = a - b;
            } else if (op.equals("*")) {
                x = a * b;
            } else {
                x = a / b;
            }
            System.out.println(x);

        }
    }
}



Measured memory_bytes: 26104
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,M;
  cin >> N >> M;
  
  vector<int>check(N,0);
  vector<int>check_w(N,0);
  int ac = 0;
  int wa = 0;
  
  for(int i=0;i<M;i++){
    int p;
    string s;
    
    cin >> p;
    cin >> s;
    
    if(s == "AC") check[p-1]++;
    else if(check[p-1] == 0) check_w[p-1]++;
  }
  
  for(int i=0;i<N;i++){
    if(check[i] != 0){
      ac++;
      wa += check_w[i];
    }
  }
  
  cout << ac << " " << wa << endl;
  
  return 0;
}



Measured memory_bytes: 1024
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

if a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2:
    print('infinity')
    exit()

if a1 * t1 + a2 * t2 < b1 * t1 + b2 * t2:
    a1, a2, b1, b2 = b1, b2, a1, a2

if a1 > b1:
    print(0)
    exit()

x = (b1 - a1) * t1
y = a1 * t1 + a2 * t2 - b1 * t1 - b2 * t2

if x % y == 0:
    print(x // y * 2)
else:
    print(x // y * 2 + 1)

Measured memory_bytes: 38528
#include <algorithm>
#include <iostream>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  vector<P> vec;
  REP(i, n) {
    int t, d;
    cin >> t >> d;
    t--;
    vec.push_back(P(d, t));
  }
  sort(ALL(vec));
  reverse(ALL(vec));
  set<int> set;
  stack<int> stack;
  ll sum = 0;
  REP(i, k) {
    if (set.count(vec[i].second)) {
      stack.push(vec[i].first);
    } else {
      set.insert(vec[i].second);
    }
    sum += vec[i].first;
  }
  ll ans = sum + set.size() * set.size();
  for (int i = k; i < n; ++i) {
    if (set.count(vec[i].second)) continue;
    if (stack.empty()) break;
    sum -= stack.top();
    stack.pop();
    set.insert(vec[i].second);
    sum += vec[i].first;
    ll res = sum + set.size() * set.size();
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}

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

bool pmem[300000];
vector<int> prime;
void init()
{
  for(int i = 2; i < 300000; i++)
  {
    if(!(i % 7 == 6 || i % 7 == 1))
      continue;
    if(pmem[i])
      continue;
    prime.push_back(i);
    for(int j = i; j < 300000; j += i)
      pmem[j] = 1;
  }
}

int main()
{
  init();
loop:
  int n;
  cin >> n;
  if(n == true)
    return 0;
  cout << n << ":";
  for(int i = 0; i < prime.size(); i++)
    if(!(n % prime[i]))
      cout << " " << prime[i];
  cout << endl;
  goto loop;
}

Measured memory_bytes: 1636
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	swap(a,b);
	swap(a,c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

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

using namespace std;

typedef long long ll;

inline int getInt(){ int s; scanf("%d\n", &s); return s; }

bool check(const vector<ll> &a, ll v, ll th){
  const int n = a.size();
  ll cnt = 0;

  for(const ll aa : a){
    // aa - n * k + (v - k) <= th
    // aa - th + v <= (n + 1)k
    // k >= (aa - th + v + n) / (n + 1)
    const ll k = (aa - th + v + n) / (n + 1);
    cnt += k;
  }

  // printf("%lld: %lld\n", v, cnt);
  return cnt <= v;
}

vector<ll> emulate(const vector<ll> &a, ll v, ll th){
  const int n = a.size();
  vector<ll> ret(n);
  for(int i = 0; i < n; i++){
    const ll aa = a[i];
    const ll k = (aa - th + v + n) / (n + 1);
    ret[i] = aa - k * n + (v - k);
  }
  return ret;
}

int main(){
  int n; cin >> n;
  vector<ll> a(n); REP(i,n) cin >> a[i];

  ll high = 1ll << 60;
  ll low = 0;
  while(low <= high){
    const ll mid = (high + low) / 2;
    if(check(a, mid, 2 * n)) high = mid - 1;
    else low = mid + 1;
  }

  ll cnt = low;
  a = emulate(a, cnt, 2 * n);

  while(true){
    auto it = max_element(a.begin(), a.end());
    if(*it < n) break;

    *it -= n + 1;
    for(auto &aa : a) aa += 1;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main() {
  int N;
  scanf("%d", &N);

  long long ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= i;
    ans %= MOD;
  }
  printf("%lld", ans);
}

Measured memory_bytes: 256
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <random>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;
using ull = __uint128_t;

using sc = signed char;
using si = signed int;
using sl = signed long long int;
using sll = __int128_t;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

namespace std {
  template <>
  struct is_integral<__int128_t> {
    constexpr static bool value = true;
  };
};

static vector<sl> Xi;
static sl N;

void solve(void) {
  sl min_cost = 1e7;
  FOR0(i, 100) {
    sl pos = i + 1;
    sl cost = 0;
    FORITER(Xi, it) {
      cost += (*it - pos) * (*it - pos);
    }
    if (cost < min_cost) {
      min_cost = cost;
    }
  }
  cout << min_cost << endl;
}

int main(void) {
  cin >> N;
  Xi.resize(N);
  FOR0(i, N) {
    cin >> Xi[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    bool ans=false;
    if(n%2==0){
        if(s.substr(0,n/2)==s.substr(n/2,n/2)) ans=true;
    }
    puts(ans?"Yes":"No");
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int RGB[3] = {0, 0, 0};
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            RGB[0]++;
        } else if (S[i] =='G') {
            RGB[1]++;
        } else {
            RGB[2]++;
        }
    }
    int pat = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < N; j++) {
            if (0 <= i-j && i+j < N && S[i-j] != S[i] && S[i] != S[i+j] && S[i+j] != S[i-j]) {
                pat++;
            }
        }
    }
    cout << (long long)RGB[0] * RGB[1] * RGB[2] - pat << endl;
}


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

# In[27]:


S = input()


# In[28]:


ZtoA = "zyxwvutsrqponmlkjihgfedcba"
diff = sorted(list(set(ZtoA)^set(S)))
if len(S) < 26:
    print(S+diff[0])
else:
    if S == ZtoA:
        print(-1)
    else:
        for i in range(25):
            if S[i] < S[i+1]:
                k = i
        a = "z"
        for i in range(k+1,26):
            if S[k] < S[i]:
                a = min(a, S[i])
        print(S[:k]+a)


# In[ ]:






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

vector<int> graph[200005];
vector<ll> cnt;

void dfs(int c, int p=-1) {
  for (int ne : graph[c]) {
    if (ne == p) continue;
    cnt[ne] += cnt[c];
    dfs(ne, c);
  }
}

int main() {
  int n, q;
  cin >> n >> q;  
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  cnt.resize(n+1);
  rep(i, q) {
    int p, q;
    cin >> p >> q;
    cnt[p] += q;    
  }
  dfs(1);
  for (int i = 1; i < n+1; i++) {
    cout << cnt[i] << ' ';
  }
  return 0;
}

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

int main(){

    int A,B;
    cin >> A >> B;

    if((A+B)%3 == 0) cout << "Possible"<< endl;
    else if (A%3 == 0) cout << "Possible"<< endl;
    else if (B%3 == 0) cout << "Possible"<< endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

f=lambda:map(int,input().split())
N,M,L=f()
G=[[0]*N for _ in [0]*N]
for _ in [0]*M:
    a,b,c=f()
    G[a-1][b-1]=c
    G[b-1][a-1]=c
    
csr=csr_matrix(G)

D=floyd_warshall(csr)
INF=float('inf')
G=[[INF]*N for _ in [0]*N]
for i in range(N):
    for j in range(N):
        if i!=j and D[i][j]<=L:
            G[i][j]=1
            G[j][i]=1
csr=csr_matrix(G)
res=floyd_warshall(csr)
Q=int(input())
for _ in [0]*Q:
    s,t=f()
    r=res[s-1][t-1]
    print(int(r-1) if r<INF else -1)

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

int main() {
  int k;
  cin >> k;
  int ans = 1, m = 7;

  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (k == 1 || k == 7) {
    cout << 1 << endl;
    return 0;
  }
  while (m != 0) {
    ans++;
    m = (10 * m + 7) % k;
  }

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


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : "\n"); return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : "}\n"); return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vl a(N); rep(i,N) cin >> a[i];
  int l = 0;
  int r = 1;
  ll stand = a[0];
  ll ans = 0LL;
  for(; l < N ; l++){
    for(;;){
      if(r==N) break;
      if(((stand&a[r])==0LL)){
        stand |= a[r];
        dump(stand,r);
        r++;
      }else break;
    }
    dump(stand,l,r);
    stand ^= a[l];
    ans += r - l;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll x,y;
    cin>>x>>y;
    ll i,j;
    for(i=0;i<=x;i++)
    {
        ll no1 = i*2;
        ll no2 = (x-i)*4;
        ll res= no1+no2;
        if(res==y)
        {
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3632
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            double exp = 0;
            if (A <= 5) { Console.WriteLine("0"); }
            else if (A <= 12) { Console.WriteLine((B/2).ToString()); }
            else { Console.WriteLine(B.ToString()); }
        }
    }
}


Measured memory_bytes: 11092
import java.io.*;
import java.util.*;

public class Main {
	static final int MOD = 1_000_000_007;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] a = new int[200_001];
		
		for(int i = 0; i < n; i++) {
			a[sc.nextInt()]++;
		}
		
		Arrays.sort(a);
		
		int sum = 0;
		
		for(int i = 0; i < a.length; i++) {
			if(a[i] != 0) sum++;
		}
		
		int res = 0;
		
		if(sum > k) {
			for(int i = 0; i < a.length; i++) {
				if(sum == k) {
					break;
				}else{
					if(a[i] != 0) {
						sum--;
						res+=a[i];
					}
				}
			}
		}
		out.println(res);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 46900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500010;
const int mod = 1e9 + 7;
int a[N];
int dp[N], sdp1[1050000], sdp2[1050000];
int bit[N];
int sum[N];
int cntt[1050000];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	bit[0] = 1;
	for(int i = 1; i < N; i++) bit[i] = (ll)bit[i - 1] * 2 % mod;
	int n; cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] ^= a[i - 1];
	}
	int V = a[n];
	if(V > 0){
		int sumv = 0, sum0 = 0;
		for(int i = 1; i <= n; i++){
			if(a[i] == V){
				dp[i] = (1 + sum0) % mod;
				sumv = (sumv + dp[i]) % mod;
			}
			else if(a[i] == 0){
				dp[i] = sumv % mod;
				sum0 = (sum0 + dp[i]) % mod;
			}
		}
		cout << dp[n] << "\n";
	}
	else{
		assert(V == 0);
		for(int i = 1; i <= n; i++)
			sum[i] = sum[i - 1] + (a[i] == 0);
		int cnt0 = sum[n - 1];
		int ans = bit[cnt0];
//		cout << "at first ans = " << ans << "\n";
//		for(int i = 1; i <= n; i++)
//			cout << a[i] << ' ';
//		cout << "\n";
		for(int i = 1; i <= n - 1; i++){
			if(a[i] == 0){
//				cout << 0 << ' ';
				continue;
			}
			int vdp;
			if(cntt[a[i]] == 0){
				vdp = 1;
			}
			else{
				vdp = ((ll)sdp1[a[i]] * sum[i] % mod + mod - sdp2[a[i]]) % mod;
				vdp = (vdp + 1) % mod;
			}
			(sdp1[a[i]] += vdp) %= mod;
			(sdp2[a[i]] += (ll)vdp * sum[i] % mod) %= mod;
			(ans += vdp) %= mod;
			cntt[a[i]]++;
//			cout << vdp << ' ';
		}
//		cout << "\n";
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    double a_yen, b_yen;
 
    cin >> a_yen >> b_yen;
 
    int a_count = 0;
 
    for (double ans = 1.0; ans <= 1009.0; ans += 1.0) {
        if (floor(ans * 0.08) == a_yen && floor(ans * 0.10) == b_yen) {
            cout << ans << endl;
            a_count++;
        }
        if (a_count) break;
    }
 
    if (a_count == 0){
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int N, P;
  scanf("%d %d", &N, &P);

  bool have_odd = false;
  REP(i, N) {
    int x;
    scanf("%d", &x);
    if (x % 2) have_odd = true;
  }

  llint ans;
  if (!have_odd) {
    ans = P == 0 ? (1LL<<N) : 0;
  } else {
    ans = (1LL << (N-1));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
flag = []
for i in range(k):
    if t[i] == 'r':
        flag.append('r')
        ans += p
    elif t[i] == 's':
        flag.append('s')
        ans += r
    elif t[i] == 'p':
        flag.append('p')
        ans += s

for i in range(k,n):
    if flag[i-k] == t[i]:
        flag.append('')
        continue
    elif t[i] == 'r':
        flag.append('r')
        ans += p
    elif t[i] == 's':
        flag.append('s')
        ans += r
    elif t[i] == 'p':
        flag.append('p')
        ans += s

print(ans)            

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

using namespace std;

int main(){
  int n;

  while(cin>>n,n){
    vector<int> s;
    int t;
    int total=0;
    int cnt=0;
    
    for(int i=0;i<n;++i){
      cin>>t;
      s.push_back(t);
    }

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

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

    cout<<total/cnt<<endl;
  }
}

Measured memory_bytes: 3104
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,t;
    cin>>n>>t;
    int ans=99999;
    
    for(int i=0;i<n;i++){
        int cost,ti;
        cin>>cost>>ti;
        
        if(ti<=t){
            ans=min(ans,cost);
        }
    }
    
    if(ans!=99999) cout<<ans<<endl;
    else cout<<"TLE"<<endl;
    
    return 0;
}

Measured memory_bytes: 256