akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s; 

    cin>>s;

    unsigned long long int sum =0 ; 

    for(int i=0 ; i<s.size() ; i++ )
    {
        sum+=s[i] -'0';
    }

    if(sum%9 ==0 )
    {
        cout<<"Yes";
    }
    else 
    {
        cout<<"No";
    }


}

Measured memory_bytes: 3752
#include<iostream>
#include<string>

int main(){

	for (int i = 0; i<9; i++){
		std::string name;
		int a, b;
		std::cin >> name >> a >> b;
		std::cout << name << " " << a + b << " " << a * 200 + b * 300 << std::endl;

	}

	return 0;
}

Measured memory_bytes: 1204
//6:48
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}

int s[33];
int e[33];
int p[8];
int main(){
        ll N,M;
        scanf("%lld %lld",&N,&M);
        for(int i = 0; i < M; i++){
                scanf("%d %d",s+i,e+i);
        }


        for(int i = 0; i < N; i++){
                p[i] = i+1;
        }

        ll ans = 0;
        do{
                char ok = true;
                for(int i = 0; i < N-1; i++){
                        char found = false;
                        for(int j = 0; j < M; j++){
                                if((s[j] == p[i] && e[j] == p[i+1]) ||
                                   (e[j] == p[i] && s[j] == p[i+1]))
                                found = true;
                        }
                        if(!found){
                                ok = false;
                                break;
                        }
                }
                //for(int i = 0; i < N; i++){
                //      printf("%d,",p[i]);
                //}printf("ok=%d\n",ok);
                if(ok) ans++;
        }while(next_permutation(p+1,p+N));

        printf("%lld\n",ans);
}

Measured memory_bytes: 128
def c_energy_drink_collector(N, M, Drinks):
    drinks = sorted(Drinks)
    needs = M
    ans = 0
    for a, b in drinks:
        buy = min(needs, b)
        ans += a * buy
        needs -= buy
        if needs == 0:
            break
    return ans

N, M = [int(i) for i in input().split()]
Drinks = [[int(i) for i in input().split()] for j in range(N)]
print(c_energy_drink_collector(N, M, Drinks))

Measured memory_bytes: 22376
#include <stdio.h>

typedef long long ll;

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

int main()
{
	ll a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF)
	{
		ll _gcd = gcd(a,b);
		printf("%lld %lld\n",_gcd,a*b/_gcd);
	}
}


Measured memory_bytes: 2568
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n, m;
  cin >> m >> n;
  vector<string> C(m);
  vector< vector<int> > A(26);
  for(int i = 0; i < m; ++i){
    cin >> C[i];
    for(int j = 0; j < n; ++j){
      if(C[i][j] != '.') A[C[i][j]-'A'].push_back(i*n+j);
    }
  }
  int ans = 0;
  for(int i = 0; i < 26; ++i){
    for(int j = 0; j < 26; ++j){
      if(A[j].empty()) continue;
      int a = A[j][0]/n, b = A[j][0]%n, c = A[j][1]/n, d = A[j][1]%n;
      bool f = true;
      for(int k = min(b,d)+1; k < max(b,d); ++k){
        if(C[a][k] != '.'){
          f = false;
          break;
        }
      }
      for(int k = min(a,c)+1; k < max(a,c); ++k){
        if(C[k][d] != '.'){
          f = false;
          break;
        }
      }
      if((a != c && b != d && C[a][d] != '.') || (a == c && abs(b-d) <= 1) || (b == d && abs(a-c) <= 1)) f = false;
      if(f){
        //cout << (char)('A'+j) << endl;
        C[a][b] = '.';
        C[c][d] = '.';
        ans += 2;
        A[j] = vector<int>(0);
        continue;
      }
      f = true;
      for(int k = min(b,d)+1; k < max(b,d); ++k){
        if(C[c][k] != '.'){
          f = false;
          break;
        }
      }
      for(int k = min(a,c)+1; k < max(a,c); ++k){
        if(C[k][b] != '.'){
          f = false;
          break;
        }
      }
      if((a != c && b != d && C[c][b] != '.') || (a == c && abs(b-d) <= 1) || (b == d && abs(a-c) <= 1)) f = false;
      if(f){
        //cout << (char)('A'+j) << endl;
        C[a][b] = '.';
        C[c][d] = '.';
        ans += 2;
        A[j] = vector<int>(0);
        continue;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3344
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            Console.ReadLine();
            var s = Console.ReadLine().Trim();
            var sa = s.Replace("IO", "A");
            var d = countA(sa, n);
            var aaa = getAns(d, n);
            var ai = getAI(sa, n);
            Console.WriteLine(ai + aaa);
        }
    }
    static int getAns(Dictionary<int, int> d, int n)
    {
        var ans = 0;
        foreach (var x in d)
            ans += (x.Key - n) * x.Value;
        return ans;
    }
    static int getAI(string s, int n)
    {
        var t = new string('A', n) + "I";
        var a = (s.Length - s.Replace(t, "").Length) / (n + 1);
        return a;
    }
    static Dictionary<int, int> countA(string s, int n)
    {
        var d = new Dictionary<int, int>();
        var sL = s.Length;
        var count = 0;
        for (int i = 0; i < sL; i++)
        {
            if (s[i] == 'A') count++;
            else
            {
                if (count >= n + 1)
                {
                    if (d.ContainsKey(count)) d[count]++;
                    else d[count] = 1;
                }
                count = 0;
            }
        }
        return d;
    }
}



Measured memory_bytes: 24460
# encoding: utf-8
N, X = map(int, input().split())

def count(level, pos):
    L_child = 2 ** ((level - 1) + 2) - 3
    P_child = 2 ** ((level - 1) + 1) - 1
    # solved
    if pos == 0: return 0 if level > 0 else 1
    elif pos < L_child + 1: return count(level - 1, pos - 1)
    elif pos == L_child + 1: return P_child + 1
    elif L_child + 1 < pos < 2 * (L_child + 1):
        return P_child + 1 + count(level - 1, pos - (L_child + 2))
    else: return 2 * P_child + 1

print(count(N, X - 1))

Measured memory_bytes: 3064
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    int k = int.Parse(input[1]);
    string s = Console.ReadLine();
    string result = string.Empty;
    
    for (int i = 0; i < n; i++) {
      if (i + 1 == k) {
        if (s[i] == 'A') { result += 'a'; }
        else if (s[i] == 'B') { result += 'b'; }
        else if (s[i] == 'C') { result += 'c'; }
      } else {
        result += s[i];
      }
    }
    Console.WriteLine(result);
  }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 105*3;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int n; 
    while (cin >> n) {
        bool ans = true;
        set<string> S;
        string last = "A";
        FOR(i,0,n) {
            string w; cin >> w;
            if (in_(w,S)) {
                ans = false;
            }
            S.insert(w);
            if (i && w[0] != last.back())
                ans = false;
            last = w;
        }
        if (ans)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n;
  cin >> n;
  ll c[n+1];
  rep(i,n)cin >> c[i];
  c[n]=inf;
  vector<int> modify;
  rep(i,n){
   if(c[i]!=c[i+1])modify.push_back(c[i]);
  }
  ll sum[200020]={};
  ll dp[200020]={};
  dp[0]=1;
  dp[1]=1;
  sum[modify[0]]=1;
  for(ll i=1;i<modify.size();i++){
    dp[i+1]=dp[i]+sum[modify[i+1]];
    dp[i+1]%=mod;
    sum[modify[i]]+=dp[i-1];
    sum[modify[i]]%=mod;
  }
  cout << dp[modify.size()-1]%mod << endl;
return 0;}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
 
using namespace std;
 
#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
 
 
#define fr(i, n) for(int i=0; i<n;i++)
#define fr1(i, n) for(int i=1; i<=n;i++) 
 
#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define nl "\n"
 
void file(){
	readf("in.txt");
    writef("out.txt");
}
 
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
typedef long long ll;
typedef pair<int,int> pii;

ll dp[101][100001];
 
int main()
{
	//file();
 
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 	
 	int N, W;	

	cin>>N>>W;

	int w[105], v[105];

	fr1(i,N)
		cin>>w[i]>>v[i];

	fr(i,N+1)
		dp[i][0] = 0;
	
	fr(i,W+1)
		dp[0][i] = 0;

	fr1(i,N){
		fr1(j,W){
			
			if(w[i] <= j){
				dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
			}
			else
				dp[i][j] = dp[i-1][j];
		}
	}

	
	cout<<dp[N][W]<<nl;

	


    return 0;
 
}

Measured memory_bytes: 79232
fn main() {
    use std::collections::HashMap;
    use std::collections::HashSet;
    let n: u64 = read();
    let m: u64 = read();
    let mut table: HashSet<u64> = HashSet::new();
    let mut ac = 0;
    let mut penalty_table: HashMap<u64, u64> = HashMap::new();
    let mut penalty = 0;
    for _ in 0..m {
        let p: u64 = read();
        let s: String = read();
        if s == "AC" {
            if !table.contains(&p) {
                ac += 1;
                table.insert(p);
                if let Some(pena) = penalty_table.get(&p) {
                    penalty += *pena;
                }
            }
        } else {
            if !table.contains(&p) {
                if !penalty_table.contains_key(&p) {
                    penalty_table.insert(p, 1);
                } else {
                    penalty_table.get_mut(&p).map(|old| *old += 1);
                }
            }
        }
    }
    println!("{} {}", ac, penalty);
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

const ll M=1e9+7,N=1e5;
ll A[N];

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


	int n,count=1;
	cin>>n;
	char A[n];
	cin>>A;
	for(int i=1;i<n;i++)
	{
		if(A[i] != A[i-1])
			count++;
	}
	cout<<count<<"\n";

	return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin>>a.at(i);
  }
  vector<int> b(n+2);
  b.at(1)=1;
  if(m==0){
    for(int i=1;i<=n;i++){
      b.at(i+1)=(b.at(i)+b.at(i-1))%1000000007;
    }
    cout<<b.at(n+1)<<endl;
    return 0;
  }
  int j=0;
  for(int i=1;i<=n;i++){
    if(i==a.at(j)){
      j=min(j+1,m-1);
    }
    else{
      b.at(i+1)=(b.at(i)+b.at(i-1))%1000000007;
    }
  }
  cout<<b.at(n+1)<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {


	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		
		
		
		if (p>=q && p>=r) {
			System.out.println(q+r);
		} else if (q>=p && q>=r) {
			System.out.println(p+r);
		} else {
			System.out.println(p+q);
		}
		


	}
	

}

Measured memory_bytes: 23252
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		int n = s.size();
		map<int,int> dp;
		dp[0] = 0;
		using bs = bitset<26>;
		bs tmp = 0;
		int ans;
		REP(i,n){
			int c = s[i]-'a';
			tmp[c] = !tmp[c];
			int mi = INF;
			REP(i,n) {
			}
			REP(j,26){
				auto t = tmp;
				t[j] = !t[j];
				auto ite = dp.find(t.to_ulong());
				if(ite != dp.end()) {
					chmin(mi, ite->S+1);
				}
			}
			{
				auto ite = dp.find(tmp.to_ulong());
				if(dp.find(tmp.to_ulong()) != dp.end()){
					chmin(mi,ite->S+1);
				}
			}
			ans = mi;

			{
				auto ite = dp.find(tmp.to_ulong());
				if(ite == dp.end()) {
					dp[tmp.to_ulong()] = INF;
				}
			}
			chmin(dp[tmp.to_ulong()], mi);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 9876
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string sT;
	cin>>sT;
	int n=sT.length();
	char *sA = new char[n+1];
	memset(sA,'g',n);
	sA[n]='\0';
	int pMax = n/2;
	int pN=0;
	int i=0;
	for (i=0;i<n;i++){
		if (sT[i]=='g'){
			if (pN<pMax){
				sA[i]='p';
				pN++;
			}else{
				break;
			}
		}
	}
	int sAN=0;
	for (i=0;i<n;i++){
		if (sA[i]=='p' && sT[i]=='p'){
		}
		if (sA[i]=='g' && sT[i]=='g'){
		}
		if (sA[i]=='p' && sT[i]=='g'){
			sAN++;
		}
		if (sA[i]=='g' && sT[i]=='p'){
			sAN--;
		}
	}
	cout<<sAN<<endl;
	delete[] sA;
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
#define ARG(x, i) (get<i> (x))
using namespace std;
 
const int maxN = 1 << 19, maxTS = maxN * 2;
const long long INF = 100000000000000000ll;

template <class T1, class T2> inline void remin(T1& a, T2 b)	{   a = min(a, (T1)b);  }

struct Tree
{
	int offset, qbegin, qend;
	long long T[maxTS], x;
	
	void qpriv(int v, int left, int right)
	{
		if (left >= qend or right <= qbegin)	
			return;
		if (left >= qbegin and right <= qend)
		{
			remin(T[v], x);
			return;
		}
		qpriv(v * 2, left, (left + right) / 2);
		qpriv(v*2+1, (left + right) / 2, right);
	}
	
	void init(int n)
	{
		for (offset = 1; offset < n; offset *= 2);
		FOR(i, 1, offset*2)
			T[i] = INF;
	}
	
	void updt(int a, int b, long long c)
	{
		qbegin = a + offset;
		qend = b + offset + 1;
		x = c;
		qpriv(1, offset, offset * 2);
	}
	
	long long query(int v)
	{
		long long res = INF;
		for (v += offset; v != 0; v /= 2)
			remin(res, T[v]);
		return res;
	}
}tree;

tuple <int, int, int> Q[maxN];

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	tree.init(m + 42);
	
	FOR(i, 0, m)
	{
		int a, b, c;
		scanf ("%d%d%d", &a, &b, &c);
		Q[i] = make_tuple(a, b, c);
	}
	tree.updt(1, 1, 0);
	sort(Q, Q+m);
	
	FOR(i, 0, m)
	{
		int a, b, c;
		tie(a, b, c) = Q[i];
		long long x = tree.query(a);
		tree.updt(a, b, x+c);
	}	
	
	long long res = tree.query(n);
	if (res == INF)
		res = -1ll;
	printf("%lld\n", res);
}
 
int main()
{
	int t;
	t = 1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

int main() {
    string S,T;
    cin >> S >> T;
    
    if(S==T){
      cout << "Yes" << endl;
      return 0;
    }

    for(int i=0;i<S.size();i++){
      S = S[S.size()-1] + S;
      S = S.substr(0,S.size()-1);
      if(S == T){
              cout << "Yes" << endl;
      return 0;
      }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
B,C=zip(*A)
D=B+C
import collections
a=collections.Counter(D)
for i in a.values():
  if i%2==1:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;



int main(){
	
	int n,m;
	cin >> n;
	m = n-(n/2);
	out(10) << (double)m/n << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    private int sum(int i, int j, int k, int l, int m, int n) {
        return 100 * i + 101 * j + 102 * k + 103 * l + 104 * m + 105 * n;
    }

    private void check(int X, int i, int j, int k, int l, int m, int n) {
        if (sum(i,j,k,l,m,n) == X) {
            System.out.println(1);
            System.exit(0);
        }
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        int N = 1000;
        for (int i = 0; X >= sum(i,0,0,0,0,0); i++) {
            for (int j = 0; X >= sum(i,j,0,0,0,0); j++) {
                for (int k = 0; X >= sum(i,j,k,0,0,0); k++) {
                    for (int l = 0; X >= sum(i,j,k,l,0,0); l++) {
                        for (int m = 0; X >= sum(i,j,k,l,m,0); m++) {
                            for (int n = 0; X >= sum(i,j,k,l,m,n); n++) {
                                check(X,i,j,k,l,m,n);
                            }
                        }
                    }
                }
            }
        }
        
        System.out.println(0);
        return;
    }

}

Measured memory_bytes: 23380
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

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

    vector<int> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int ans=inf;
    for(int i=1;i<=100;++i)
    {
        int cur=0;
        for(int j=0;j<n;++j)
            cur+=(v[j]-i)*(v[j]-i);

        ans=min(ans,cur);
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N, M, X; cin >> N >> M >> X;
	vector<int> C(N);
	int A[14][14];

	REP(i, N){
		cin >> C[i];
		REP(j,M){
			cin >> A[i][j];
		}
	}

	int ans = INF;
	int MAX = pow(2, N);

	REP(i,MAX){
		bitset<14> b(i);
		vector<int> ab(M, 0);
		int sum = 0;
		REP(j,N){
			if(b[j]){
				sum += C[j];
				REP(k,M){
					ab[k] += A[j][k];
				}
			}
		}
		bool ok = true;
		REP(j,M){
			if(ab[j] < X) ok = false;
		}

		if(ok) ans = min(ans, sum);
	}

	if(ans == INF) ans = -1;
	cout << ans << endl;



	return 0;

}


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

using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{
  ll to,id;
};
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

pair<UM<ll,ll>,UM<ll,ll>> compress(vi v){
  vi unique; unique.PB(v[0]);
  FOR(i,1,ll(v.size())) if(v[i]!=v[i-1]) unique.PB(v[i]);
  ll N=unique.size();
  UM<ll,ll> newToOld,oldToNew;
  sort(ALL(unique));
  REP(i,N) {oldToNew[unique[i]]=i; newToOld[i]=unique[i];}
  return {oldToNew,newToOld};
}

struct RSQRAQ{
  ll size;
  ll *t1,*t2;
  RSQRAQ(ll sz){
    ll logsize; for(logsize=0;(1ll<<logsize)<=sz;logsize++);
    size=(1ll<<logsize);
    t1=new ll[size*2-1];
    t2=new ll[size*2-1];
    REP(i,size*2-1) t1[i]=t2[i]=0;
  }
  void add(ll s,ll t,ll x){
    add(s,t,0,size,0,x);
  }
  void add(ll s,ll t,ll l,ll r,ll k,ll x){
    if(r<=s||t<=l||r<=l) return;
    if(l+1==r) {t1[k]+=x; return;}
    if(s<=l&&r<=t) {t1[k]+=x*(r-l); t2[k]+=x*(r-l); return;}
    t1[k]+=(min(r,t)-max(l,s))*x;
    ll mid=(l+r+1)/2;
    add(s,t,l,mid,k*2+1,x);
    add(s,t,mid,r,k*2+2,x);
  }
  ll getSum(ll s,ll t){
    return getSum(s,t,0,size,0);
  }
  ll getSum(ll s,ll t,ll l,ll r,ll k){
    if(r<=s||t<=l||r<=l) return 0;
    if(l+1==r) return t1[k];
    if(s<=l&&r<=t) return t1[k];
    ll mid=(l+r+1)/2;
    t1[k*2+1]+=t2[k]/2; t2[k*2+1]+=t2[k]/2;
    t1[k*2+2]+=t2[k]/2; t2[k*2+2]+=t2[k]/2;
    t2[k]=0;
    return getSum(s,t,l,mid,k*2+1)+getSum(s,t,mid,r,k*2+2);
  }
};

int main() {
  ll N,K; cin>>N>>K;
  vi a(N); REP(i,N) cin>>a[i];
  vi b(N+1); b[0]=0; REP(i,N) b[i+1]=b[i]+a[i];
  vi c(N+1); REP(i,N+1) c[i]=b[i]-i*K;
  pair<UM<ll,ll>,UM<ll,ll>> cmp=compress(c);
  UM<ll,ll> oldToNew=cmp.first,newToOld=cmp.second;
  vi d(N+1); REP(i,N+1) d[i]=oldToNew[c[i]];

  ll ans=0;
  RSQRAQ rsq(2*N+1);
  for(ll i=N;i>=0;i--) {
    ll cnt=rsq.getSum(d[i],2*N);
    ans+=cnt;
    rsq.add(d[i],d[i]+1,1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 55952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll H, W;
    cin >> H >> W;
    vvll c(10, vll(10, INF));
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    vll cnt(10, 0);
    rep(i, H) rep(j, W) {
        ll a;
        cin >> a;
        if(a == -1) continue;
        else cnt[a]++;
    }

    rep(k, 10) rep(i, 10) rep(j, 10) chmin(c[i][j], c[i][k] + c[k][j]);

    ll ans = 0;
    rep(i, 10) ans += cnt[i] * c[i][1];
    cout << ans << endl;
}


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

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>=b){
        cout << "No" << endl;
        return 0;
    }
    if(b>=c){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<cassert>

using namespace std;

template< typename T>
struct edge { 
   int from, to; 
   T cost; 
   edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template< typename T>
using EDGE = vector< edge< T > >;

template< typename T>
vector< T > bellman_ford(EDGE< T > &es, int V, int s) {
   const auto INF = numeric_limits< T >::max();
   vector< T > dist(V, INF);
   dist[s] = 0;
   for (int i = 0; i < V - 1; i++) {
      for (auto &e : es) {
         if (dist[e.from] == INF) continue;
         dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
      }
   }
   for (auto & e : es) {
      if (dist[e.from] == INF) continue;
      if (dist[e.from] + e.cost < dist[e.to]) return vector< T >();
   }
   return dist;
}

const int MAXN = 2501;
bool used1[MAXN];
bool used2[MAXN];
vector<int> G1[MAXN], G2[MAXN];

void bfs1(int s) {
   used1[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G1[cur]) {
         if (used1[g]) continue;
         used1[g] = true;
         q.push(g);
      }
   }
}

void bfs2(int s) {
   used2[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G2[cur]) {
         if (used2[g]) continue;
         used2[g] = true;
         q.push(g);
      }
   }
}

int main() {
   int N, M, P;
   cin >> N >> M >> P;
   int A[M], B[M], C[M];
   for (int i = 0; i < M; i++) {
      cin >> A[i] >> B[i] >> C[i];
      A[i]--;
      B[i]--;
      C[i] = -1 * (C[i] - P);
      G1[A[i]].push_back(B[i]);
      G2[B[i]].push_back(A[i]);
   }
   memset(used1, false, sizeof(used1)); 
   memset(used2, false, sizeof(used2)); 

   bfs1(0);
   bfs2(N - 1);
   /*
   for (int i = 0; i < N; i++) {
      cout << i << " " << used1[i] << " " << used2[i] << endl;
   }
   */
   EDGE< int > edges;
   
   for (int i = 0; i < M; i++) {
      if (!used1[A[i]]) continue;
      if (!used1[B[i]]) continue;
      if (!used2[A[i]]) continue;
      if (!used2[B[i]]) continue;
      // cout << A[i] << " " << B[i] << " " << C[i] << endl;
      if (A[i] == B[i] && C[i] < 0) {
         cout << "-1" << endl;
         return 0;
      }
      if (A[i] == B[i]) continue;
      edges.emplace_back(A[i], B[i], C[i]);
   }
   
   auto res = bellman_ford(edges, N, 0);
   if (res.empty()) cout << "-1" << endl;
   else {
      assert(res[N - 1] != numeric_limits<int>::max());
      cout << max(0, -1 * res[N - 1]) << endl;
   }
   return 0;
}


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

void fnLinkedListSet(list<int> &rltnNum)
{
  list<int>::iterator itltn;
  list<int>::iterator itltEND = rltnNum.end();
  string sCmd;
  int nMaxCmd, nNum;

  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> sCmd;
    if (sCmd == "insert")
    {
      cin >> nNum;
      rltnNum.push_front(nNum);
    }
    else if (sCmd == "deleteFirst")
      rltnNum.pop_front();
    else if (sCmd == "deleteLast")
      rltnNum.pop_back();
    else if (sCmd == "delete")
    {
      cin >> nNum;
      for (itltn = rltnNum.begin(); itltn != itltEND; ++itltn)
        if (*itltn == nNum)
        {
          rltnNum.erase(itltn);
          break;
        }
    }
  }
}

void fnLinkedListGet(const list<int> &cnrltnNum)
{
  list<int>::const_iterator itltn;
  list<int>::const_iterator itltEND = cnrltnNum.end();

  for (itltn = cnrltnNum.begin(); itltn != itltEND; ++itltn)
  {
    if (itltn != cnrltnNum.begin()) cout << " ";
    cout << *itltn;
  }
  cout << endl;
}

int main()
{
  list<int> ltnNum;
  fnLinkedListSet(ltnNum);
  fnLinkedListGet(ltnNum);

  return 0;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N, ans = 1;
    string S;
    cin >> N >> S;
    for (int i = 0; i < N - 1; i++)
    {
        if (S[i] != S[i + 1])
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 512
n = int(input())
m = 1
k = n
s = ''
while True:
    k -= 26**m
    if k > 0:
        m +=1
    else:
        break
n -= 26*(26**(m-1)-1)//25
for i in range(m):
    j = ((n-1)//26**i + 1)
    if j%26 != 0:
        s += chr(j%26+96)
    else:
        s += 'z'
print(s[::-1])

Measured memory_bytes: 9024
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, q) = parse!(it, 2);
    let mut events = vec![];
    for _ in 0..n {
        let (s, t, x): (isize, isize, isize) = parse!(it, 3);
        events.push((s - x, true, x));
        events.push((t - x, false, x));
    }
    events.sort();
    events.reverse();
    let mut stops = std::collections::BTreeSet::<isize>::new();
    for _ in 0..q {
        let d = parse!(it);
        while let Some(&(t, add, x)) = events.last() {
            if t > d {
                break;
            }
            if add {
                stops.insert(x);
            } else {
                stops.remove(&x);
            }
            events.pop();
        }
        println!("{:?}", stops.iter().next().unwrap_or(&-1)); // DEBUG
    }
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 26352
while line = gets
  26.times{
    if line.include?("the") || line.include?("this") || line.include?("that")
      puts line
      break
    end
    line.size.times{|i|
      if "a" <= line[i] && line[i] <= "z"
        line[i] = (line[i].ord + 1).chr
        line[i] = "a" if line[i] > "z"
      end
    }
  }
end

Measured memory_bytes: 8780
#include<stdio.h>
int main(void){
	int i=0,l;
	char s[20];
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++);
	for(i--;i>=0;i--){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1984
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val n = 3

  val c = (0 until n).map {
    br.readLine().split(" ").map { it.toInt() }
      .toIntArray()
  }

  val b = c[0]
  val a = IntArray(n, { i -> c[i][0] - b[0] })

  fun evalute() =
    (1 until n).all { i ->
      (1 until n).all { j ->
        c[i][j] == (a[i] + b[j])
      }
    }

  val ans = if(evalute()) "Yes" else "No"

  println(ans)
}

Measured memory_bytes: 35528
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

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

  int n;
  cin >> n;
  vector<int> a(n), nxt(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int64> A(n + 1), B(n + 1);
  for (int i = 0; i < n; ++i) {
    A[i + 1] = A[i] + a[i];
    B[i + 1] = B[i] ^ a[i];
  }
  int last = n;
  for (int i = n - 1; i >= 0; --i) {
    nxt[i] = last;
    if (a[i]) last = i;
  }
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    int x = i;
    for (int k = 0; k <= 100; ++k) {
      if (x == n || A[x + 1] - A[i] != (B[x + 1] ^ B[i])) {
        ret += x - i;
        break;
      }
      x = nxt[x];
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;

struct group {
    int c0, c1, id;

    bool operator<(const group& who)const {
        return 1LL * c0 * who.c1 < 1LL * c1 * who.c0;
    }
};

int n, i, x, aux;
int p[maxN], dad[maxN];
int cnt0[maxN], cnt1[maxN];
priority_queue<group> H;
ll ans;

int Find(int x) {
    if (dad[x] == x) return x;
    dad[x] = Find(dad[x]);
    return dad[x];
}

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 2; i <= n; i++) scanf("%d", &p[i]);
    for (i = 1; i <= n; i++) {
        dad[i] = i;
        scanf("%d", &x);
        if (x == 0) cnt0[i] = 1;
        else        cnt1[i] = 1;

        if (i != 1)
            H.push({cnt0[i], cnt1[i], i});
    }

    while (!H.empty()) {
        auto act = H.top();
        H.pop();

        if (dad[act.id] != act.id) continue;
        if (act.id == 1) continue;
        if (cnt0[act.id] != act.c0) continue;
        if (cnt1[act.id] != act.c1) continue;

        aux = Find(p[act.id]);
        dad[act.id] = aux;
        ans += 1LL * cnt1[aux] * cnt0[act.id];

        cnt0[aux] += cnt0[act.id];
        cnt1[aux] += cnt1[act.id];
        if (aux != 1)
            H.push({cnt0[aux], cnt1[aux], aux});
    }

    printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 7284
#include<stdio.h>

int main(void){
    int N;
    int i;

    scanf("%d",&N);

    int A[N];

    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    int max=0;

    for(i=0;i<N;i++){
        if(max<A[i]){
            max=A[i];
        }
    }
    int s_max=0;
    int count=0;
    for(i=0;i<N;i++){
        if(A[i]==max){
            count++;
            A[i]=0;
        }
        if(s_max<A[i]){
            s_max=A[i];
        }
    }

    for(i=0;i<N;i++){
        if(count>1){
            printf("%d\n",max);
        }else{
            if(A[i]==0){
                printf("%d\n",s_max);
            }else{
                printf("%d\n",max);
            }
        }
    }

    return 0;
}

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

const int MOD = 1000000007;
vector<long long> Power2(60);

void InitializePower2(void){
    Power2[0] = 1LL;
    for(int i=1; i<60; i++){
        Power2[i] = Power2[i-1] * 2 % MOD;
    }
}

int main(void){

    int N;
    cin >> N;

    vector<long long> A(N);

    for(int i=0; i<N; i++)cin >> A[i];
    InitializePower2();

    long long res = 0;

    for(int i=0; i<60; i++){
        int num0 = 0;
        for(int j=0; j<N; j++){
            if(A[j]%2==0)num0++;
            A[j] = A[j]/2;
        }
        res += Power2[i]*num0%MOD*(N-num0)%MOD;
        res = res % MOD;
    }

    cout << res << endl;

    return 0;
}

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

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

    vector<pair<int64_t,int>> shop(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        shop[i] = make_pair(a,b);
    }
    sort(shop.begin(),shop.end());
    int buy=0;
    int64_t sum = 0;

    for(int i=0;i<n;i++){
        if(buy+shop[i].second < m){
            buy += shop[i].second;
            sum += shop[i].first*shop[i].second;
            //cout << buy << sum << endl;
        }
        else{
            int buy_num = m - buy;
            sum += buy_num*shop[i].first;
            //cout << buy << " "<<buy_num<< endl;
            cout << sum << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int[] num = new int[2*N];
    int min = 1001;
    //String str = sc.next();
    for(int i=0; i<2*N; i++){
        num[i] = sc.nextInt();
    }    
    for(int i=0; i<N; i++){
        //System.out.println(i+":"+num[2*i]+"-"+num[2*i+1]);
        if(num[2*i+1] > T){
            num[2*i] = 1001;
        }
    }
    
    for(int i=0; i<N; i++){
        if(min > num[2*i]){
            min = num[2*i];
            //System.out.println(i+":"+min);
        }
    }
    //if(str[0].equals("H"));
    if(min == 1001){
        System.out.println("TLE");
    }else{
    System.out.println(min);
    }
  }
}


Measured memory_bytes: 23764
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    N, K, S = MAP()

    ans = []
    for i in range(N):
        if i < K: ans.append(S)
        else:
            if S-1 >= 1: ans.append(S-1)
            else: ans.append(S+1)

    print(*ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 49392
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

L,R,d = LI()

ans = 0
for i in range(L,R+1):
    if i%d == 0:
        ans += 1

print(ans)

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

static const int MAX = 1e+5;
vector<int> adj[MAX];
int p[MAX];
int n;

void bfs(int s){
    for(int i = 0; i < n; i++){
        p[i] = -1;
    }
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(auto v : adj[u]){
            if(p[v] != -1) continue;
            p[v] = u;
            q.push(v);
        }
    }
}

int main(){
    int m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    bfs(0);
    cout << "Yes\n";
    for(int i = 1; i < n; i++){
        cout << p[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10380
n, d = map(int, input().split())

x, y = [0] * n, [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

cnt = 0
for i in range(n):
    if pow(x[i]**2+y[i]**2, 0.5) <= d:
        cnt += 1

print(cnt)

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

int main()
{
    int N, K;
    cin >> N >> K;
    int ans = 1;
    for (int i = 0; i < N; i++)
    {
        if (ans + K > ans * 2)
        {
            ans *= 2;
        }
        else
        {
            ans += K;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,K=LI()
S=input()

cnt = 0
lst = None
RNGS=[]
for i in range(N):
    if lst and lst != S[i]:
        RNGS.append((lst, cnt))
        cnt = 0
    cnt += 1
    lst = S[i]
RNGS.append((lst, cnt))

# print(RNGS)

mod_cnt = 0
if len(RNGS) >= 3:
    for i in range(0, len(RNGS)-2, 2):
        if mod_cnt < K:
            lr, num = RNGS[i+1]
            lr = 'L' if lr ==  'R' else 'R'
            mod_cnt += 1
            RNGS[i+1] = (lr, num)

# print(RNGS)
if mod_cnt < K:
    print(len(S) - 1)
else:
    prev = None
    res = 0
    for i in range(len(RNGS)):
        lr, num = RNGS[i]
        res += num
        if not prev or prev != lr:
            res -= 1
        prev = lr
    print(res)


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

int main() {
  int A,B,C,K;
  cin >>A >>B >>C >>K;
  int sum=0;
  for(int i=0;i<K;i++){
    if(A>0){
      sum++;
      A--;
    }
    else if(B>0){
      B--;
    }
            else if(C>0){
              sum--;
              C--;
            }
  }
  cout <<sum <<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while (1) {
        if (b >= c) {
            cout << "Yes\n";
            return 0;
        }
        c -= b;
        if (d >= a) {
            cout << "No\n";
            return 0;
        }
        a -= d;
    }
}


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

int main() {
    int n;cin>>n;
    int t,x,y;
    t=x=y=0;
    int f=1;
    for (int i=0;i<n;i++) {
        int nt,nx,ny;
        cin>>nt>>nx>>ny;
        int dt=nt-t;
        int dd=abs(x-nx)+abs(y-ny);
        f&=dd<=dt&&dt%2==dd%2;
        t=nt,x=nx,y=ny;
    }
    if (f)
        puts("Yes");
    else
        puts("No");
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=a*b;
  int y=c*d;
  
  if(x<y){
    cout<<y<<endl;
  }
  else{
    cout<<x<<endl;
  }
}

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

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

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

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

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, k; cin>>n>>k;

	cout << n-k+1 << "\n";
	return 0;
}


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

using namespace std;

const int N = 200000 + 77 , Mod = 1000000007;
int n , h[N] , a[N];
long long Fen[N] , A;
inline void Upd(int x , long long val){
   for(;x < N;x += x & - x)
      Fen[x] = max(Fen[x] , val);
}
inline long long Get(int x){
   long long res = 0;
   for(;x;x -= x & - x)
      res = max(res , Fen[x]);
   return res;
}
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 1;i <= n;++ i)
      cin >> h[i];
   for(int i = 1;i <= n;++ i)
      cin >> a[i];
   for(int i = 1;i <= n;++ i){
      long long t = Get(h[i]);
      A = max(A , t + a[i]);
      Upd(h[i] , t + a[i]);
   }
   cout << A;
   return 0;
}


Measured memory_bytes: 3328